"no matching architecture in universal wrapper", but file has it

We build some C++ code that uses Tensorflow Lite on multiple platforms. I'm trying to link it into our iOS build. I created a universal shared library with a couple of shared libraries built by that team. They build them as individual shared libraries with one architecture per file (one for macOS, one for iOS arm64, and one for iOS x86). I put the two iOS files together using lipo, and I was able to link and run in the Simulator. Unfortunately, I can't exercise that code path in the Simulator (for other reasons), so I built and ran on a device.


But when I try to run on a device, I get


dyld: Library not loaded: @rpath/libtensorflowlite.so
  Referenced from: /private/var/containers/Bundle/Application/E3E3B0E9-B36E-4ADB-9FFC-CA2D6D2A8AC8/MyApp.app/MyApp
  Reason: no suitable image found.  Did find:
  /private/var/containers/Bundle/Application/E3E3B0E9-B36E-4ADB-9FFC-CA2D6D2A8AC8/MyApp.app/Frameworks/libtensorflowlite.so: no matching architecture in universal wrapper

I know the App Store doesn't like x86 bits in universal shared libraries, so I used lipo in an Xcode build phase to remove the x86 part, and now my file looks like:


$ file /Users/rmann/Library/Developer/Xcode/DerivedData/MyApp-fdskkibuvbsubudkmqtgsjxmyqme/Build/Products/Debug-iphoneos/MyApp.app/Frameworks/libtensorflowlite.so
/Users/rmann/Library/Developer/Xcode/DerivedData/MyApp-fdskkibuvbsubudkmqtgsjxmyqme/Build/Products/Debug-iphoneos/MyApp.app/Frameworks/libtensorflowlite.so: Mach-O universal binary with 1 architecture: [arm64:Mach-O 64-bit dynamically linked shared library arm64]
/Users/rmann/Library/Developer/Xcode/DerivedData/MyApp-fdskkibuvbsubudkmqtgsjxmyqme/Build/Products/Debug-iphoneos/MyApp.app/Frameworks/libtensorflowlite.so (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64

But it still doesn't see it.
I do something similar with another library we get from a third party, and everything works fine. How can I inspect this further to determine what the issue is? Thanks.

Replies

HI @JetForMe
I am also doing the same like you. Basically I want to build a SDk for an App. So, i just created a framework like you and want ot run it but unfortunately getting an error:

"Could not find module 'SDK' for target 'x86_64-apple-ios-simulator'; found: arm64, armv7-apple-ios, arm64-apple-ios, arm, armv7"
Therefore, I am also using the lipo command put th efile together but still getting the same error. Is this the same issue right?
After putting the files together I am also getting the Error: Reason: no suitable image found.

I am also looking forward the answer.