Xamarin Team talk about pros and cons better than me. So follow the link below.

http://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/

Shared project

> You only plan to target Android, iOS and Windows Phone
> You want to start coding as soon as possible
> You don’t plan to use Xamarin but you want to see how it works from a closer look
> You are familiar with #if directives

It works like if you were adding files as link. Every platform’s project will add the files from the shared project as a link. It means that when you add a file in the shared project, every reliant project will add this file.

PCL project

> You plan to use the project in other projects like an ASP.NET project, a WPF project, a Windows 10 app etc.
> You want to reduce dependencies
> You want to separate concerns

Conclusion

I’ve tried both way. I prefer the Portable approach. I’ve always been a huge fan of Portable Class Library and dependency injection. I felt I was coding the base of my application faster with the Shared project at the beginning. As an exemple, you can log what you want in the shared project because you have access to the Debug class. With PCL project, you don’t. So, you have to create an interface of a LogService and its implementation on each platform (e.g. AndroidLogService, iOsLogService, WinPhoneLogService). It’s the same thing with HTTP request : in the PCL project, you don’t have access to the HttpClient class. Thus, we have to make some extra work that isn’t necessary with the shared project.

If you don’t know PCL and dependency injection yet, you may start with the PCL approach as you will learn new interesting things.

Leave a Reply

Your email address will not be published. Required fields are marked *