Search code examples
iosstatic-librariesuniversal-binary

ios static library Undefined symbols for architecture x86_64


lipo -info libXxxx.a Architectures in the fat file: libXxxx.a are: armv7 i386 arm64

But compiler in the dependant project is giving linking error,

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_ClassXXXX", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Am I missing something? All the lib project's target have Architectures: Standard Architectures (armv7, arm64) and Valid Architectures arm64, armv7, armv7s

in my lipo command while making universal binary I am lipo-ing both from iphonesimulator and iphoneos folder.


Solution

  • Your main clue is that it says "symbol(s) not found for architecture x86_64" instead of "symbol(s) not found for architecture i386".

    The fix is to tweak your build settings to allow a 32-bit build.

    1) Select your project file in the Project Navigator (the left sidebar)

    2) Select your project's target (first entry under TARGETS in the panel that just came up)

    3) Find the "Architectures" setting (make sure "All" is selected if you can't find "Architectures")

    4) Change it from "Standard Architectures" to "Universal" (or explicitly "32-bit" if you prefer)

    You should be able to build after doing this.