my code smells
my code smells

Reputation: 461

Xamarin Mobile - Platform-specific assemblies in shared PCL?

We have a shared PCL that uses the Xamarin.Mobile dll to read contact's from a user's device and show a subset of them in our application. Because the Android and iOS versions of the dll are different we are required to reference both in our shared PCL and then the OS-specific versions in their respective projects. The issue is that you cannot reference two dlls with the same name.

Is there a way to reference both dlls in the shared PCL using some kind of alias? Or is there a better way to implement this so that we can access contacts on different devices using Xamarin.Mobile in the same solution?

Upvotes: 2

Views: 476

Answers (1)

brhlavinka
brhlavinka

Reputation: 98

You will be better off referencing Xamarin.Mobile in your platform specific projects:

  • Reference Android Xamarin.Mobile (dll) in your Android project
  • Reference iOS Xamarin.Mobile (dll) in your iOS project

If you want to abstract that functionality into a shared PCL, you can do so using a shared interface and injected (dependency injection) platform specific implementations.

Upvotes: 4

Related Questions