Good morning
I am building package for Xamrin.Forms. I follow how its done by James Montenango
Here are some important pieces of my .csproj
<TargetFrameworks>netstandard2.0;MonoAndroid10.0;Xamarin.iOS10</TargetFrameworks>
<ItemGroup>
<Compile Include="**\*.shared.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) ">
<PackageReference Include="XTricks.Shared" Version="1.0.1" />
<PackageReference Include="Xamarin.Essentials" Version="1.6.1" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
<PackageReference Include="Xamarin.GooglePlayServices.Location" Version="118.0.0.1" />
<PackageReference Include="XTricks.Shared" Version="1.0.1" />
<PackageReference Include="Xamarin.Essentials" Version="1.6.1" />
<Compile Include="**\*.android.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) ">
<PackageReference Include="Xamarin.Essentials" Version="1.6.1" />
<PackageReference Include="XTricks.Shared" Version="1.0.1" />
<Compile Include="**\*.apple.cs" />
</ItemGroup>
Everything is working except one important thing. I would like to have two implementation of the same class for Android and for iOS.
For this purpose I declare and interface as:
IMyService.shared.cs
And I create two classes, one in Android folder called: MyService.android.cs which implements IMyService.shared.cs and second in Apple folder called MyService.apple.cs.
Now as is done in above library I would like to use service in shared code.
private static IMyService Service
{
get
{
#if NETSTANDARD1_0 || NETSTANDARD2_0
return null;
#else
return new MyService(); // And this code is red one. MyService cannot be found.
#endif
}
}
Basically I am stucked there. Does anyone know how to move foward?