I am trying to set up DependencyService to call platform specific code in a Multiplatform project.
When calling Dependency.Get<IService>()
in the Shared project I get null.
The Service inside iOS does not seem to register.
I have tried to register it like this: [assembly: Dependency(typeof(Service))]
- on top of the namespace declaration inside the iOS project. Which I have gotten to work inside a Xamarin.Forms project. And I have also tried to call DependencyService.Register<Service>();
inside a Init method in the iOS project - calling it from a Xamarin.Forms iOS project in AppDelegate - made for testing the library.
The Shared
project and iOS
project does not seem to share the same DependencyService
.
How can I call platform specific code in the iOS project from the Shared project with DependencyService?