Skip to content

Facing issues when adding platform-specific DLLs (iOS and Android) to a .NET MAUI app and referencing them in the project file. #24490

@kalyan173106

Description

@kalyan173106

Basically, I am building a .NET MAUI iOS and Android app using a Kotlin Multiplatform (KMM) SDK.

Step 1

I created a KMM sample SDK and generated the .xcframework for iOS and AAR for Android.

Step 2

Everything works fine when I follow the approach below for both Android and iOS.

I created:

an iOS binding library

an Android binding library

Android

For Android, I added the AAR to the Android binding project, generated the DLL, and referenced it in the MAUI Android app like this:

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0-android'">
  <Reference Include="AndroidBindingNewSDK">
    <HintPath>..\..\AndroidBindingNewSDK\AndroidBindingNewSDK\bin\Debug\net9.0-android\AndroidBindingNewSDK.dll</HintPath>
  </Reference>
</ItemGroup>

iOS

For iOS, I added the .xcframework to the iOS binding project, generated the ApiDef, built the DLL, and referenced it in the MAUI iOS app like this:

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0-ios'">
  <Reference Include="iOSBindingRDMobileSDK">
    <HintPath>..\..\iOSBindingRDMobileSDK\iOSBindingRDMobileSDK\bin\Debug\net9.0-ios\iOSBindingRDMobileSDK.dll</HintPath>
  </Reference>
</ItemGroup>

Problem Statement

However, I do not want to share the binding projects with the client.
I want to provide only the DLLs, and the client should be able to use them directly.

Current Behavior
iOS

When I add only the DLL to the MAUI app, I get a clang linker error.
If I add both the DLL and the .xcframework to the MAUI app, everything works correctly.

<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
  <Reference Include="iOSBindingRDMobileSDK">
    <HintPath>libs\iOSBindingRDMobileSDK.dll</HintPath>
  </Reference>
  <NativeReference Include="libs\shared.xcframework">
    <Kind>Framework</Kind>
    <SmartLink>True</SmartLink>
    <ForceLoad>True</ForceLoad>
  </NativeReference>
</ItemGroup>

My question is: Is there a way to make iOS work using only the DLL, without requiring the .xcframework?

Android

For Android, when I add both the DLL and the AAR directly to the MAUI app, I still encounter an issue:

<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
  <Reference Include="AndroidBindingNewSDK">
    <HintPath>libs\AndroidBindingNewSDK.dll</HintPath>
  </Reference>
  <AndroidLibrary Include="libs\shared-debug.aar">
    <Bind>false</Bind>
  </AndroidLibrary>
</ItemGroup>

Android error:

invalid file path 'C:\b\net9.0-android\lp\161.stamp'

Goal

My goal is to distribute only DLLs and make them work correctly for both Android and iOS, without requiring the client to reference the original AAR or .xcframework files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions