Reputation: 11
Hoi, i am using Xamarin Studio on OSX since one week and i have a problem with a PCLProject. How can i tell XS to use a specific class for each platform ? e.g i have a class Connector.cs :IConnector in the PCL-Project but i want to use AndroidConnector.cs: IConnector in the .Droid Project and IOSConnector.cs : IConnector in the .iOS Project. How can i tell this to Xamarin Studio to do so ? Is there a tutorial ? The specific Class are not known in the PCL-Project so it doesent built. Thanks for your help
Upvotes: 0
Views: 83
Reputation: 7594
If you are using Xamarin.Forms, you can use the Dependency Service.
https://developer.xamarin.com/guides/xamarin-forms/dependency-service/
Xamarin.Forms allows developers to define behavior in platform-specific projects. DependencyService then finds the right platform implementation, allowing shared code to access the native functionality.
If you are using classic Xamarin, you can write a plugin to accomplish the same goals.
http://motzcod.es/post/104507063997/what-exactly-is-a-plugin-for-xamarin
This post specifically references nuget packages, but you don't have to use nuget. You can write your own "plugins" in your solution.
Upvotes: 0