How to use dependency service in xamarin native (Xamarin.iOS and Xamarin.Android)

XamDev03XamDev03 USMember ✭✭
edited July 2018 in General

Hello Folks,

I need suggestion on one point. Let me explain the problem in detail.
I am working on one of my Xamarin native project for Android and iOS. Here, I have two different projects for Android and iOS.

For instance, Android Project Contains total 5 projects:

  • DemoAndroid
  • DemoAndroid.Common
  • DemoAndroid.SQLite
  • DemoAndroid.Services
  • DemoAndroid.Models

iOS Project Contains total 5 projects:
* DemoIOS
* DemoIOS.Common
* DemoIOS.SQLite
* DemoIOS.Services
* DemoIOS.Models

These both projects(iOS and Android) have different core projects instead of common as we are using Xamarin platform. Both core version projects are a mostly similar version of the code. no changes in the code.

Currently, I am working to make a single core based project for Android and iOS.
I am facing the issue like, DemoAndroid.Services and DemoIOS.Services have some platform-specific code of Android and iOS respectively (i.e, date converter, activity indicator etc). I had removed platform specific code and make sure that I will use C# based code in PCL. Now, I need a help here is that, How can I use platform specific code in PCL multiplatform project. Do we have anyway?

I have checked the dependency services but this is working with Xamarin forms and I have Xamarin native code. Do we have any way to stabilize my issue? In addition, I am planning to convert the whole UI version in the Xamarin forms but I want to use same PCL core projects inside the Forms Projects.

1. Do we have any way to stabilize this issue in xamarin native?
2. Are there any possibilities to use same PCL core projects in Xamarin Forms projects? (AFAIK, this is possible but I want to make sure from experts here. That will boost my confidence to move forward to doing this process.)
3. Suggest me if I am doing anything wrong here. Also, suggest me the best way to full-filling all these requirements.

Thanks in advance..!!!


Sign In or Register to comment.