Reputation: 1070
I am trying to understand PCL project in Xamarin. Visual Studio giving Class Library and Class Library (Portable)
templates.
I am able to refer Class Library project in Android and iOS, then what is the purpose of Class Library (Portable)?
I am aware PCL is for referencing project in platform independent cases, which is based on .net profiles and of limited kind.
If I am able to refer normal library project in Android & iOS then why in Xamarin documentation PCL or Shared is recommended for code sharing
For example, if I keep all the data related code in common either PCL or shared, then to create sqlite connection, I need to refer sqlite in all the three platforms, but in normal library project that is not required, because Environment.GetFolderPath is available in library but not in PCL, because of platform independent.
Upvotes: 0
Views: 99
Reputation: 3698
Its just because of code sharing.
i.e: You're implementing some database wrapper class like storing & fetching some tables. Via PCL project you won't need to write for each platforms, write once(in PCL) then use it for all platforms. This kind of works required some native implementation for each platforms(even paths for files are different). In that phase you needed to implement something Native and pass to some references into your PCL project via some interface.
In other words PCL libraries are just intersection of .NEt features by supported all platforms you specified, but class libraries might have some native references.
Upvotes: 0