Search code examples
c#xamarinxamarin.androidxamarin.ioscross-platform

Write platform specific code in crossplatform xamarin project


I tried to use the Xamarin.Android namespace in my crossplatform Xamarin project. When i now build the .iOS Project, i get the notification, that this namespace is, obviously, not existing for iOS.

How can i write platform specific Code, where i use platform specific libraries ?

I already checked the Microsoft Docs but i did not find any information that could solve my problem.

PS: This is my first contribution to Stack Overflow, so feel free to ask for more detailed information.


Solution

  • Welcome to stack overflow.

    https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction

    Above is a link to DependencyService documentation. DependencyService allows you as a developer to call platform-specific code from your Xamarin.Forms shared code.