简体   繁体   中英

Xamarin.Forms PCL

i was just wondering what the benefits are in using PCL with Xamarin.Forms. I mean you share the Code between each Platform anyway. In Xamarins native approach it is quite clear. So maybe anybody can tell me why to use PCL in Xamarin.Forms?

PCL allows the maximum in code sharing across platforms. PCL will by it's very nature limit you to using only those API's that can be shared from platform to platform.

While you can use Shared Projects, you will find yourself using compiler directives and making coding sacrifices that can lead to bad coding practices across anything but the smallest of projects.

Using the Xamarin Forms 2.3.3 or later you can of course embed Platform Specific Controls in your Xamarin Forms pages in your PCL and they will only render when run on the platform.

In addition of maximum code sharing, it allows you to follow best practices like SOLID.

Also, please remember that there are 3 choices (not only 2):

  • Portable Class Library
  • Shared Library
  • .NET Standard Library

.NET Standard Library is still an ongoing work in process, so it's not there yet. But, it will be the way to go!. So, PCLs today can give you an excelent migration path to the .NET Standard Library way tomorrow.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM