Bengi Besceli
Bengi Besceli

Reputation: 3748

Portable and Shared projects of Xamarin

I'm new on creating Xamarin projects.
What is the difference between portable and shared projects ?
I guess one is portable and the other is shared but what is the aim of these
and which one I should use for my cross-platform forms mobile applicaton?

Portable and Shared projects on Xamarin

Thanks in advance

Upvotes: 0

Views: 196

Answers (2)

Giorgi
Giorgi

Reputation: 30873

Taken directly from Xamarin website:

Shared Projects – Use the Shared Asset Project type to organize your source code, and use #if compiler directives as required to manage platform-specific requirements.

Portable Class Libraries – Create a Portable Class Library (PCL) targeting the platforms you wish to support, and use Interfaces to provide platform-specific functionality.

Upvotes: 1

Sreeraj
Sreeraj

Reputation: 2434

Portable means PCL and shared is Shared Asset Project. Essentially both can be used for sharing code across platforms. You can find the difference explained by Xamarin in their documentation.

In simple my own words, when code sharing is done with a PCL, the shared code is compiled initially and then is referenced by Android and iOS projects. So only code that can be compiled by all platforms can be included in PCL type. Whereas in shared asset project, the code files are added to individual platforms and then compiled. So we can include platform specific codes using Pre-processor directives. Each method has its own pros and cons. You can decide which to chose after considering them all.

Upvotes: 1

Related Questions