Dynamic library image doesn't contain x86_64,

2020-07-26 14:03发布

问题:

I'm trying to build dynamic library for iOS, combined with architectures

  • armv7
  • armv7s
  • arm64
  • i386
  • x86_64

Here is my target's Build Settings

As you can see I've added x86_64 and i386 to Architectures and Valid Architectures, also Build Active Architecture Only is set to NO.

So after building my binary, I'm checking supported architectures by running file myDl.dylib in Terminal

myDl.dylib (for architecture armv7):    Mach-O dynamically linked shared library arm  
myDl.dylib (for architecture arm64):    Mach-O 64-bit dynamically linked shared library

So it means it has been compiled for armv7 and arm64, and dlopen() fails on simulator with error "Unsupported architecture".

What am I doing wrong?

PS. When I use custom build script and use there "lipo" tool to create fat library, it works fine, but I don't like that way, and I want to get it normal working on Xcode.

回答1:

Set armv7,armv7s and arm64 in valid architecture and make sure if you use any thirdparty framework that must be include 64 bit support.