I have a .net Maui Native iOS binding of some iOS framework. I managed to bind successfully. However, I want to create a .Net Maui Class library to consume the iOS native binding. See my project structure below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">16.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NativeSdk.Android\NativeSdk.Android.csproj" />
<ProjectReference Include="..\NativeSdk.iOS\NativeSdk.iOS.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0-ios' ">
<ProjectReference Include="Path\To\Your\iOSNativeBindingProject.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="Platforms\Android\Models\" />
<None Remove="Platforms\Android\Aar\" />
<None Remove="Platforms\Android\Aar\TransaktSDK.aar" />
</ItemGroup>
<ItemGroup>
<Folder Include="Platforms\Android\Models\" />
<Folder Include="Platforms\Android\Aar\" />
</ItemGroup>
<ItemGroup>
<AndroidAarLibrary Include="Platforms\Android\Aar\TransaktSDK.aar">
<AndroidSkipResourceProcessing></AndroidSkipResourceProcessing>
</AndroidAarLibrary>
</ItemGroup>
<ItemGroup>
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="SecureServiceInfo.cs">
<ExcludeFromCurrentConfiguration>true</ExcludeFromCurrentConfiguration>
</Compile>
</ItemGroup>
</Project>
I tried to add to add the other platforms on my Native binding project to avoid compatibility issues. I also added condtions to try to only compile with ios. When I do that all the files in the apiDefinition class break. See below my native iOS project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-ios;net7.0;net7.0-android;net7.0-maccatalyst</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<IsBindingProject>true</IsBindingProject>
</PropertyGroup>
<!-- <ItemGroup>
<Compile Remove="StructsAndEnums.cs" />
<Compile Remove="ApiDefinitions.cs" />
</ItemGroup>-->
<ItemGroup>
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinitions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0-ios'">
<NativeReference Include="..\..\..\..\..\Downloads\nativeSKD_iOS\NativeSDK.xcframework">
<Kind>Framework</Kind>
<Frameworks>Foundation</Frameworks>
<ForceLoad>True</ForceLoad>
</NativeReference>
</ItemGroup>
</Project>
I've been stuck on this for days. I just want to create a maui class library including my native iOS binding project