Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Bindings with XCFramework format and Nuget MT5211 error #12087

Closed
juraskrlec opened this issue Jul 8, 2021 · 10 comments
Closed

iOS Bindings with XCFramework format and Nuget MT5211 error #12087

juraskrlec opened this issue Jul 8, 2021 · 10 comments
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS need-info Waiting for more information before the bug can be investigated
Milestone

Comments

@juraskrlec
Copy link

Hi, Jura from the Microblink team here :) I am having some issues using xcframework in our bindings after building Nuget and using them in our Sample applications. Everything that I am writing here is based on our BlinkID for iOS SDK and our Xamarin Project supporting our SDK.

Steps to Reproduce

  1. Add .xcframework to our iOS Bindings project from BlinkID for iOS SDK.
  2. Change .xcframework from static to a framework in properties.
  3. Check that our bindings .csproj project have

<PropertyGroup> <NoBindingEmbedding>true</NoBindingEmbedding> </PropertyGroup>

refereeing to the issue 10774

  1. Build our iOS bindings and create a Nuget package
  2. Go to our sample project and add Nuget package to our Sample iOS project.

I see both iOSBinding.dll and iOSBinding.resources with manifest and Microblink.xcframework in it, and that should work, again seeing issue 10774, but after creating Nuget package, I am getting MT5211 error.

As it seems, that is still not working, as mentioned here.

Expected Behavior

Build and run BlinkID iOS Sample app.

Actual Behavior

89 errors, all saying the same thing for different classes. Example:
Error MT5211: Native linking failed, undefined Objective-C class: MBDateResult. The symbol 'OBJC_CLASS$_MBDateResult' could not be found in any of the libraries or frameworks linked with your application. (MT5211) (BlinkIDSample)

Environment

=== Visual Studio Community 2019 for Mac ===

Version 8.10.5 (build 16)
Installation UUID: be50f84a-9e91-4325-8fc8-0d8129d70d56
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c736)

Package version: 612000140

=== Mono Framework MDK ===

Runtime:
Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit)
Package version: 612000140

=== Roslyn (Language Service) ===

3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb

=== NuGet ===

Version: 5.9.0.7134

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.301/Sdks
SDK Versions:
5.0.301
5.0.202
5.0.201
5.0.100
3.1.410
3.1.408
3.1.407
3.1.300
3.1.101
3.0.101
3.0.100
2.1.701
2.1.700
2.1.505
2.1.504
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
5.0.7
5.0.5
5.0.4
5.0.0
3.1.16
3.1.14
3.1.13
3.1.4
3.1.1
3.0.1
3.0.0
2.1.23
2.1.18
2.1.15
2.1.14
2.1.12
2.1.11
2.1.9
2.1.8

=== .NET Core 3.1 SDK ===

SDK: 3.1.410

=== Xamarin.Profiler ===

Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 11.3.0.4 (Visual Studio Community)
Commit: xamarin-android/d16-10/ae14caf
Android SDK: /Users/juraskrlec/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.0
SDK Build Tools Version: 27.0.3

Build Information:
Mono: b4a3858
Java.Interop: xamarin/java.interop/d16-10@f39db25
ProGuard: Guardsquare/proguard@912d149
SQLite: xamarin/sqlite@85460d3
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-10@c5732a0

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/juraskrlec/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.10.0.12
Hash: e240b8c
Branch: remotes/origin/d16-10
Build date: 2021-06-01 18:26:34 UTC

=== Android Device Manager ===

Version: 16.10.0.14
Hash: e340248
Branch: remotes/origin/d16-10
Build date: 2021-06-01 18:26:52 UTC

=== Xamarin Designer ===

Version: 16.10.0.119
Hash: 36a2d986f
Branch: remotes/origin/d16-10
Build date: 2021-06-02 19:41:34 UTC

=== Apple Developer Tools ===

Xcode 12.5.1 (18212)
Build 12E507

=== Xamarin.Mac ===

Version: 7.14.0.24 (Visual Studio Community)
Hash: c4b89cd
Branch: d16-10
Build date: 2021-06-15 22:03:00-0400

=== Xamarin.iOS ===

Version: 14.20.0.24 (Visual Studio Community)
Hash: c4b89cd
Branch: d16-10
Build date: 2021-06-15 22:03:01-0400

=== Build Information ===

Release ID: 810050016
Git revision: d6bd382154950cedf91ffdf19704a7c61888a3b4
Build date: 2021-07-02 06:38:37-04
Build branch: release-8.10

=== Operating System ===

Mac OS X 10.16.0
Darwin 20.3.0 Darwin Kernel Version 20.3.0
Thu Jan 21 00:07:06 PST 2021
root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64

@mandel-macaque
Copy link
Member

Thanks for the report, can you please provide me pointers to the project to test it on my side and make sure we are in the same page. If I can repro the issue I'll ping the right person to look at it.

@mandel-macaque mandel-macaque added the need-info Waiting for more information before the bug can be investigated label Jul 19, 2021
@mandel-macaque mandel-macaque added this to the Future milestone Jul 19, 2021
@juraskrlec
Copy link
Author

Hi @mandel-macaque, yes, sure.

So, clone this repo and check out Advanced topics. In short, ApiDefinitions and Structs are ok; you need to add Microblink.xcframework from the latest release to Bindings and add it iOS Bindings project and change .xcframework from static to a framework in properties. After that, you need to create a Nuget package from that iOS Bindings and use that local iOS Nuget in iOS Bindings Sample project .

I hope this helps! Please let me know if I can help with something else :)

@juraskrlec
Copy link
Author

Hi @mandel-macaque

any update on this?

@juraskrlec
Copy link
Author

Hi @mandel-macaque

sorry to bother you, but is there any chance for someone to check this and see what's going on, or if there is a workaround?

@chamons chamons added bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS and removed need-info Waiting for more information before the bug can be investigated labels Nov 2, 2021
@juraskrlec
Copy link
Author

Hi @chamons, @mandel-macaque

Any update on this? :)

@chamons
Copy link
Contributor

chamons commented Apr 29, 2022

As there are no linked PRs or comments, no we don't have any update as of yet. Much of the team has been busy with the NET6 transition.

@rolfbjarne
Copy link
Member

This has been fixed for .NET.

In any case I believe I was able to hack a bit to embed the xcframework in the nupkg correctly in Xamarin.iOS by doing:

The contents of the zip file are:

$ unzip -l ./bin/Debug/BlinkID.iOS.Binding.5.19.0.nupkg
Archive:  ./bin/Debug/BlinkID.iOS.Binding.5.19.0.nupkg
  Length      Date    Time    Name
---------  ---------- -----   ----
      509  10-10-2022 23:16   _rels/.rels
     1253  10-10-2022 23:16   BlinkID.iOS.Binding.nuspec
 90195043  10-10-2022 23:16   lib/xamarinios10/BlinkID.iOSBinding.resources.zip
   410624  10-10-2022 23:16   lib/xamarinios10/BlinkID.iOSBinding.dll
   152436  10-10-2022 23:16   lib/xamarinios10/BlinkID.iOSBinding.pdb
      583  10-10-2022 23:16   [Content_Types].xml
      699  10-10-2022 23:16   package/services/metadata/core-properties/07fa6e423bdb41218460f6301f808ec3.psmdcp
---------                     -------
 90761147                     7 files

and while I haven't tried this, it looks correct.

Please let us know if this works for you, and if it doesn't, please include a binlog of the build failure.

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label Oct 10, 2022
@ghost
Copy link

ghost commented Oct 10, 2022

Hi @juraskrlec. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ghost
Copy link

ghost commented Oct 17, 2022

Hi @juraskrlec. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you.

@ghost ghost closed this as completed Oct 17, 2022
@busec0
Copy link

busec0 commented Nov 8, 2022

Having the same issue with a different package I'm working with. I'm getting:

MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: TestNativeClass. The symbol '_OBJC_CLASS_$_TestNativeClass' could not be found in any of the libraries or frameworks linked with your application.

I've tried different configurations and applying the diffs suggested by @rolfbjarne here: https://gist.github.com/rolfbjarne/b1f55d3b4f410c08082edab6c982eba3

I'm getting the same NuGet package structure, .dll, .pdb and zipped resources, but referencing it in a Xamarin.iOS application ends up with MT5211 errors.

I've also tried with NoBindingEmbedding as false, where I'm getting a larger .dll but that doesn't work either. In a .NET 6 binding library that's working fine I see the .resources folder isn't zipped. Tried that as well, same output.

Any ideas? @juraskrlec did you get a chance to try @rolfbjarne's suggestion?

@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS need-info Waiting for more information before the bug can be investigated
Projects
None yet
Development

No branches or pull requests

5 participants