Archived Forum Post

Index of archived forum posts


xcode 7 MakeUniversal lib fails with recommended script

Sep 21 '15 at 12:12

Hi ,

I am using the chilkat libs as instructed at and I am encountering the follwoing error like other persons as well. I am developing for iOS only , but receive the following error:

ld: in /Users/.../lib/libchilkatIos.a(CkoCrypt2.o), building for iOS simulator, but linking in object file built for OSX, for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am using the following script at the BUILD PHASES / RUN SCRIPT section at Xcode 7 to create one universal lib ( that worked fine at xcode 6.4 ) :

cd lib /usr/bin/libtool -static i386/libchilkatIos.a x86_64/libchilkatIos.a armv7s/libchilkatIos.a armv7/libchilkatIos.a arm64/libchilkatIos.a -o libchilkatIos.a cd ..

Can somone help, please ? It´s really urgent !

best regards


Accepted Answer

Note: The iOS 9 version should be for iOS 6.0 and above. The important thing is that bitcode is enabled on this build, and that it's built using Xcode 7.


Thanks Jan,

You provided this additional information in private email, and I think this is the solution:

In Xcode 7, the linker enforces that all files linked together were built for the same platform. You control the platform via -mmacosx-version-min=XX or -miphoneos-version-min=XX compiler options.

You can see which platform an object file was built for by running “otool -lv” on the .a (or .o) file. and look for LC_VERSION. You should see LC_VERSION_MIN_IPHONEOS, LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_WATCHOS, or LC_VERSION_MIN_TVOS.

Besides now longer being able to mix OSX intel binaries and simulator binaries, this means going forward, you need to build different libraries for the iOS, watchOS, and tvOS simulators.

I think the individual libs are fine. For example, i386/libchilkatIos.a is correctly compiled with LC_VERSION_MIN_MACOSX and armv7s/libchilkatIos.a is correctly compiled with LC_VERSION_MIN_IPHONEOS. I think the solution is to produce two separate "universal" libs:

You would run two libtool commands:

/usr/bin/libtool -static i386/libchilkatIos.a x86_64/libchilkatIos.a 
  -o libchilkatSimIos.a

/usr/bin/libtool -static armv7s/libchilkatIos.a armv7/libchilkatIos.a arm64/libchilkatIos.a
   -o libchilkatIos.a