I have fruitlessly been trying to get my Swift (xcode) framework bound to my MAUI project. The documentation is very confusing. It is unclear whether this only works when using xCode and Visual Studio for Mac, or whether it can work in a PC / Mac setup.
Thus far:
- I have created an Xcode Framework project on the Mac
- Exposed the bits I want to make available in MAUI using the @objc directive
- Build my 64/32 bit builds
- Used
lipoto convert them into a FAT - Copied these frameworks over to my PC and put them where my binding project can find them
- Used sharpie to create my ApiDefinition.cs and StructsAndEnums.cs
- Referenced my binding project in my MAUI project, correctly limiting it to net9-ios target
- Can see my project reference / namespaces in the object explorer in VS
- However this is as far as I can get. There as 2 notable problems:
(a) I cannot reference the namespace in my binding project in my Platforms\iOS code – it won’t compile, and code completion will not show the namespaces
(b) The dll which is referenced from the binding library is only 12K in size (if it’s a thin wrapper, I don’t see why this should be an issue – however, somehow all the framework files need pulling across for the final build)
My binding project project file looks like:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0-ios</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<IsBindingProject>true</IsBindingProject>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
</ItemGroup>
<ItemGroup>
<NativeReference Include="Frameworks\MyFramework.xcframework">
<Kind>Framework</Kind>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
</NativeReference>
</ItemGroup>
</Project>
Can anyone help me get this over the line?