Search code examples
xamarin.iosxamarin.androidxamarinportable-class-libraryxamarin.mobile

How to share Xamarin.Mobile related code in a cross-platform application


I'm working on cross-platform mobile app and as I understood Xamarin.Mobile was developed in order to increase code sharing in cross-platform applications. Though I couldn't put it into PCL. What I got is platform specific implementation of each API aspect (contacts, geolocation, etc).

Same time file links wouldn't work as well because Geolocator (just for example) constructor contains platform specific arguments (Android.Context in case of MonoDroid).

How should I share Xamarin.Mobile related logic across Monodroid, Monotouch and WP? Did I miss some Xamarin concept?

Thanks, Alexey Strakh


Solution

  • Xamarin.Mobile doesn't currently support portable libraries. It would need to be refactored so that it included interfaces in a portable library and implementations for them in platform-specific libraries.

    I don't know if that's on their roadmap, but it is open source at https://github.com/xamarin/Xamarin.Mobile, so if you're feeling industrious you could send them a pull request for it. :)