Xamarin Shared Library and PCL
Asked Answered
G

1

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.

Galitea answered 17/8, 2015 at 6:11 Comment(0)
D
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.

Digiacomo answered 17/8, 2015 at 10:50 Comment(4)
Wosi, Can you do the same things with the camera using the PCL that you could using the platform specific code?Taryn
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.Digiacomo
Why would a developer not want to use PCL then? Easier to maintain the SAP? Something else?Taryn
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.Digiacomo

© 2022 - 2024 — McMap. All rights reserved.