Skip to content

How to build iOS (.NET 7) Binding Library wrapping iOS Framework Native Reference? #18402

@syewchuk

Description

@syewchuk

I can't figure out how to create a binding library for iOS (.NET 7). I create the binding project, and it seems to build, but when I reference it in an iOS application project it fails to build with these errors:

2>C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\16.4.7054\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(332,3): warning MT0079: The recommended Xcode version for Microsoft.iOS 16.4.7054 is Xcode 14.3 or later. The current Xcode version (found in /Applications/Xcode.app/Contents/Developer) is 14.2.
2>
2>C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\16.4.7054\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(332,3): warning MT1302: Could not extract the native library 'GoogleMapsUtils.framework' from 'C:/Users/syewchuk/source/repos/iOSBindingsTest/GoogleMapsUtils.Bindings/bin/Debug/net7.0-ios/GoogleMapsUtils.Bindings.dll'. Please ensure the native library was properly embedded in the managed assembly (if the assembly was built using a binding project, the native library must be included in the project, and its Build Action must be 'ObjcBindingNativeLibrary').
2>
2>C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\16.4.7054\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(332,3): error MT0140: File '/Users/cba/Library/Caches/Xamarin/mtbs/builds/iOSBindingsTest/abdb101264ed277c1cd210d89aa5ad2301fb4b242da08f93aa98c8981a4c0d42/obj/Debug/net7.0-ios/iossimulator-x64/linker-cache/GoogleMapsUtils.framework/GoogleMapsUtils' is not a valid framework.
2>
2>C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\16.4.7054\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(332,3): error MT2342: The linker step 'Extract Binding Libraries' failed during processing: File '/Users/cba/Library/Caches/Xamarin/mtbs/builds/iOSBindingsTest/abdb101264ed277c1cd210d89aa5ad2301fb4b242da08f93aa98c8981a4c0d42/obj/Debug/net7.0-ios/iossimulator-x64/linker-cache/GoogleMapsUtils.framework/GoogleMapsUtils' is not a valid framework.
2>
2>C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\16.4.7054\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(332,3): error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information.
2>C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\16.4.7054\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(373,3): error MSB3371: The file "obj\Debug\net7.0-ios\iossimulator-x64\linked\Link.semaphore" cannot be created. Could not find a part of the path 'C:\Users\syewchuk\source\repos\iOSBindingsTest\iOSBindingsTest\obj\Debug\net7.0-ios\iossimulator-x64\linked\Link.semaphore'.
2

There is very little documentation on how to bind to a .framework library. Does anyone have any ideas on whether this is possible and what might be wrong?

I see some similarities to this issue, but I could not find an answer there:
dotnet/maui#8000

Steps to Reproduce

  1. Pair to Mac
  2. Build the Binding Project
  3. Build the Application Project => Errors

Expected Behavior

Project should build without error and then be launchable in simulator

Actual Behavior

Build fails with errors

Environment

Visual Studio 2022; Windows 10
Paired Mac: XCode 14.2; macOS Monterey

Version information
Microsoft Visual Studio Community 2022
Version 17.6.2
VisualStudio.17.Release/17.6.2+33723.286
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

ASP.NET and Web Tools   17.6.326.62524
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.6.326.62524
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   17.6.326.62524
Azure Functions and Web Jobs Tools

C# Tools   4.6.0-3.23259.8+c3cc1d0ceeab1a65da0217e403851a1e8a30086a
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.4.21 (main@8f226a8)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

GitExtensions   1.0
Git Extensions is a graphical user interface for Git that allows you to control Git without using the command-line

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio   17.6.41 (790a401)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core)   17.6.0.2326105+37f2727000f6a964584cafb86e69cf0b39baecb7
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.6.13.0
Microsoft SQL Server Data Tools

TypeScript Tools   17.0.20329.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.6.0-3.23259.8+c3cc1d0ceeab1a65da0217e403851a1e8a30086a
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.6.0-beta.23174.5+0207bea1afae48d9351ac26fb51afc8260de0a97
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSPackage Extension   1.0
VSPackage Visual Studio Extension Detailed Info

Xamarin   17.6.0.251 (d17-6@318364c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.6.6.0 (remotes/origin/d17-6@cb430751d1)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   17.6.32 (98c12a2)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   13.2.0.6 (d17-5/a200af1)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: 6dd9def
    Java.Interop: xamarin/java.interop/d17-5@149d70fe
    SQLite: xamarin/sqlite/3.40.1@68c69d8
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@9f02d77


Xamarin.iOS and Xamarin.Mac SDK   16.4.0.6 (97731c92c)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

msbuild_2023-06-04.zip

Example Project (If Possible)

iOSBindingsTest.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    binding-projectsIssue or PR that affects binding projectsbugIf an issue is a bug or a pull request a bug fix

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions