23

What is the exact difference between xamarin shared project and portable class library?

When to use shared library and when to use portable class library?

Is this possible to write native functionality in shared projects like showing alert,accessing camera and use it for both android and iOS?

Can anyone please explain me.

Wosi
  • 41,986
  • 17
  • 75
  • 82
PC Parker
  • 257
  • 2
  • 7

1 Answers1

34

I personally perefer PCLs because the code is much easier to read without any compiler directives. Using MVVMCross you are able to use plenty of plugins via NuGet. So you don't need to write your own classes for camera access, showing alerts etc.

Wosi
  • 41,986
  • 17
  • 75
  • 82
  • Wosi, Can you do the same things with the camera using the PCL that you could using the platform specific code? – johnny Oct 18 '16 at 14:48
  • Of course! Using platform specific implementations for camera access via dependency injection hidden behind platform independent interfaces you are actually running platform specific code from within a PCL. – Wosi Oct 18 '16 at 14:57
  • Why would a developer not want to use PCL then? Easier to maintain the SAP? Something else? – johnny Oct 18 '16 at 15:15
  • Personal preference. It's sometimes easier to use #ifdef in order to implement things (slightly) different per platform. And maybe there are just history reasons for using shared projects: Stable PCL support for Xamarin did not arrive until early 2013. – Wosi Oct 18 '16 at 15:34