Closed dwightbennett closed 6 months ago
- Add the libmbedtls.a file for the ios project
The problem is that there are two variations of the arm64 architecture, one for the simulator and one for device, and they can't both exist inside a single static library (.a file).
Your existing libmbedtls.a file has the arm64 architecture, but for device. In .NET 8, when you build for the simulator, we automatically default to building for arm64 for the simulator, but that doesn't work because the arm64 bits in the .a file aren't the right ones (legacy Xamarin didn't support arm64 in the simulator, this is why it worked there).
The proper fix is to use an xcframework, which can contain native code for all platforms and architectures Apple supports.
Here's some documentation about xcframeworks from Apple, there are also numerous other guides online:
If you got the native library from a third-party vendor, the easiest is to ask them to provide the xcframework (they'll likely have one already, because any of their customer using Xcode would have the same problem).
Some more information can be found here: https://github.com/xamarin/xamarin-macios/wiki/.NET-8-release-notes#default-runtimeidentifiers
Description
I am attempting to create a wrapper of the C library MBedTLS. I have used this library successfully in our application with a Xamarin Bindings library for over 4 years. We are porting our application to .Net Maui and started receiving a clang++ error when attempting to build iOS. Android has no problems whatsoever. I originally followed along with this tutorial when i setup the Xamarin Bindings library and it worked perfectly. I attached an example project to the ticket. The error says i am missing Undefined symbols for architecture arm64 and then a list of missing methods. When i run a lipo command on my .a file i get
Architectures in the fat file: libmbedtls.a are: x86_64 arm64 arm64e
So i know i have a build for arm64. When i run the commandnm -g libmbedtls.a
I can see that_cert_get_name
does exist. I will paste the whole output below. I have a feeling that the linker for ios is linking out the library but i cannot figure out how to tell .net maui to stop linking it. I have tried turning the linker completely off but ti still gives me the error. I know i've seen other clang++ issues in the backlog and i hope this isn't a duplicate, but nothing i've tried in the other issues has fixed this build error. Thank you for any work arounds you can find or links to documentation.Steps to Reproduce
Expected Behavior
.Net Maui application builds and deploys successfully.
Actual Behavior
App fails to build with a clang++ error shown in build logs
Environment
v0.10.61 (pre-release)
``` ```Build Logs
Output of
nm -g libmbedtls.a
nm-output.txtExample Project
Here is an example project that includes a basic .net maui app that references the bindings project. MauiBuildError.zip
it wouldnt let me just upload the .a file so i put it in a folder and compressed it here. library.zip
Not sure if its of any use but my csproj for my bindings project looks like this.
Again thank you for your help with this issue. I'm willing to try about anything and if you need anything else i'll be happy to get you the information.