πŸ“± Publishing IPA When Using Native Interop in .NET MAUI

Ali RazaAli Raza
3 min read

πŸš€ Introduction

When working with Native Interop in .NET MAUI, integrating Swift or Objective-C code via Native Bindings requires extra steps while publishing your iOS app. πŸ“²

This guide covers the essential steps to ensure your app is correctly signed, linked, and uploaded to the App Store. βœ…

πŸ”§ Prerequisites

Before you proceed, make sure you have:

βœ”οΈ A .NET MAUI project with Native Interop (Swift/Objective-C binding).
βœ”οΈ An Apple Developer Account with the necessary certificates & provisioning profiles.
βœ”οΈ Xcode & Visual Studio (Mac or Windows with a Mac build agent).
βœ”οΈ A physical device for testing before publishing.

1️⃣ Setup a Valid Provisioning Profile

πŸ› οΈ 1.1 Ensure Correct Build Configuration

Before building your IPA, ensure that your main .NET MAUI iOS project has a valid provisioning profile:

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0-ios|AnyCPU'">
      <CodesignProvision>Apple Distribution</CodesignProvision>
      <CodesignKey>Apple Distribution: Testing, Inc. (LKCGHZJYCR)</CodesignKey>
</PropertyGroup>

πŸ”Ή Use Manual or Automatic provisioning based on your workflow.

βœ”οΈ This ensures your app is correctly signed for distribution.
βœ”οΈ You can verify profiles in Xcode β†’ Settings β†’ Accounts β†’ Manage Certificates.

2️⃣ Configure SDKs & Native Libraries in the iOS Binding Project

Your iOS binding library project must include all necessary SDKs and native references. Make sure your .csproj file contains the correct settings:

 <NativeReference Include="StripePaymentSheet.xcframework">
        <Kind>Framework</Kind>
        <SmartLink>False</SmartLink>
        <ForceLoad>true</ForceLoad>
        <Frameworks>UIKit Foundation</Frameworks>
        <Visible>true</Visible>
    </NativeReference>

     <NativeReference Include="Stripe3DS2.xcframework">
        <Kind>Framework</Kind>
        <SmartLink>False</SmartLink>
        <ForceLoad>true</ForceLoad>
        <Frameworks>UIKit Foundation</Frameworks>
        <Visible>true</Visible>
    </NativeReference>

     <NativeReference Include="StripeApplePay.xcframework">
        <Kind>Framework</Kind>
        <SmartLink>False</SmartLink>
        <ForceLoad>true</ForceLoad>
        <Frameworks>UIKit Foundation</Frameworks>
        <Visible>true</Visible>
    </NativeReference>

       <NativeReference Include="StripeCore.xcframework">
        <Kind>Framework</Kind>
        <SmartLink>False</SmartLink>
        <ForceLoad>true</ForceLoad>
        <Frameworks>UIKit Foundation</Frameworks>
        <Visible>true</Visible>
    </NativeReference>

      <NativeReference Include="StripePayments.xcframework">
        <Kind>Framework</Kind>
        <SmartLink>False</SmartLink>
        <ForceLoad>true</ForceLoad>
        <Frameworks>UIKit Foundation</Frameworks>
        <Visible>true</Visible>
    </NativeReference>

     <NativeReference Include="StripePaymentsUI.xcframework">
        <Kind>Framework</Kind>
        <SmartLink>False</SmartLink>
        <ForceLoad>true</ForceLoad>
        <Frameworks>UIKit Foundation</Frameworks>
        <Visible>true</Visible>
    </NativeReference>

      <NativeReference Include="StripeUICore.xcframework">
        <Kind>Framework</Kind>
        <SmartLink>False</SmartLink>
        <ForceLoad>true</ForceLoad>
        <Frameworks>UIKit Foundation</Frameworks>
        <Visible>true</Visible>
    </NativeReference>

     <BundleResource Include="StripePaymentSheet.xcframework/**/Stripe_StripePaymentSheet.bundle" />

πŸ”Ή ForceLoad = true ensures the framework is forcefully loaded at runtime.
πŸ”Ή SmartLink = False prevents the linker from stripping required code.
πŸ”Ή Include all necessary frameworks like UIKit, Foundation, etc.

3️⃣ Ensure Proper Linking with XcodeProject

To properly link your native Xcode project, include the following in your csproj:

<XcodeProject Include="../native/NewBinding/NewBinding.xcodeproj">
  <SchemeName>NewBinding</SchemeName>
  <!-- Metadata applicable to @(NativeReference) will be used if set, otherwise the following defaults will be used: -->
  <Kind>Framework</Kind>
  <SmartLink>true</SmartLink>
  <IsCarthageFramework>false</IsCarthageFramework>
  <Visible>False</Visible>
</XcodeProject>

βœ… Key Configurations:
βœ”οΈ <Kind>Framework</Kind> ensures it's recognized as a framework.
βœ”οΈ <SmartLink>true</SmartLink> optimizes the linking process.
βœ”οΈ <IsCarthageFramework>false</IsCarthageFramework> if not using Carthage.

4️⃣ Check for "Do Not Embed" in Xcode

πŸ” Final Step Before Publishing!
1️⃣ Open your project in Xcode.
2️⃣ Go to Project Navigator (⌘ + 1) β†’ Select your project.
3️⃣ Under Frameworks, Libraries, and Embedded Content, ensure that any linked libraries (like .framework or xcframework files) are set to "Do Not Embed".

5️⃣ Build Each Project Individually βœ…

Before attempting to publish the IPA, make sure that each project (including the native binding project, the iOS project, and the .NET MAUI project) builds successfully.

6️⃣ Building & Publishing the IPA

Run the following command:

dotnet publish -f net9.0-ios -c Release -p:RuntimeIdentifier=ios-arm64

🎯 Conclusion

Publishing an IPA with Native Interop in .NET MAUI requires proper provisioning, linking, signing, and checking embedding settings in Xcode. By following these steps, you can successfully deploy your app without issues. πŸš€

πŸ’¬ Questions or issues? Drop a comment below! πŸ‘‡πŸ”₯

0
Subscribe to my newsletter

Read articles from Ali Raza directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ali Raza
Ali Raza

πŸš€ Tech Lead | .NET MAUI Expert | Mobile App Developer I'm Ali Raza, a passionate Tech Lead with over 6 years of experience in mobile app development. I specialize in .NET MAUI/Xamarin and have led multiple high-impact projects, including enterprise apps, fintech solutions, and eSIM technology. πŸ”Ή What I Do: βœ” .NET MAUI & Xamarin – Building cross-platform apps with robust architectures βœ” eSIM & Fintech Apps – Leading innovations in digital connectivity & finance βœ” Performance Optimization – Creating high-quality, scalable mobile solutions βœ” Mentorship & Community Sharing – Helping developers master .NET MAUI πŸ“’ Sharing Weekly Insights on .NET MAUI/Xamarin to help developers level up! Follow me for deep dives into Native Interop, API Optimization, and Advanced UI/UX techniques. Let’s connect and build something amazing! πŸš€