I am building a static library. The build setting has the Architectures set to: $(ARCHS_STANDARD)
which is shown as Standard Architectures (armv7, armv7s, arm64)
I build the lib choosing iOS Device AND then using the simulator (for example iPhone Retina).
Now that I have two builds (one inside Debug-iphoneos
and the other inside Debug-iphonesimulator
, I use lipo -create
to create the aggregated lib:
lipo -create path/to/first/lib /path/to/second/lib -o MyLib.a
If I used this library in another project to simulate on any iOS device with 64-bit architecture, it gives symbol(s) not found for architecture x86_64
. What really makes me so angry that the lib project itself is inside a workspace with another project that use the lib. I can simulate on 64-bit iOS simulator! (on all simulators and devices for that matter). What am I doing wrong?
Notes:
- This is not duplicate Q. Before accusing me of that (since this is my second day trying to fix this stupid issue), I did search on Stack and Google. All answers don't help.
- I am using Xcode 5.1.1.
Go to your application project Target and look in Library Search Path.
Now check that your library file path should be written in double quotes:
If there is no double quote then just add them and compile the project.
Hope it will work for you.
I encountered this with a framework lib I'm using in one of my apps, when I tried to test it in iPhone Retina 64bit simulator.
I simply added
x86_64
as an architecture to build for and set it to always build for all architectures. Worked a charm.The
lipo
tool can not only create fat mach-o binaries, but it can inspect them:xcrun lipo -info /path/to/libThing.a
This will output what architectures are in the file. Before you join binaries using lipo, run this to make sure the architectures you expect are present. It's also a good idea to run this on the product of a fat binary join.
In your case you need:
iPhoneSDK Configuration: armv7, armv7s, arm64
iPhoneSimulator Configuration: i386, x86_64
It seems that the iPhoneSimulator build product is not producing an x86_64 binary based on your question. Check your build configuration - in particular, "Build Active Architectures Only" (
ONLY_ACTIVE_ARCH
) should be set to NO. The default is for this to be NO for Release, but YES for debug. If it is YES, only one architecture will be in the build product.I had the same trouble with building static library.
Finally I have found the basic solution. (You need to build universal library for
x86_64
/armv7
/armv7s
/arm64
)1) Click on the project file
2) Click on the target
3) Open
"Build Phases"
4) Open
"Run Script"
5) Add
"/bin/sh"
and the script below6) Hit
"cmd + B"
(Build Project)7) Open Product in
Finder
8) Navigate 1 directory up ("cmd + ↑"), and you will see
"Release-universal"
directory.There will be your
"fat/universal"
library, You are ready to go!