I'm making a C library for Xcode project, and successfully compiled with -arch armv7
, it can be used on iPhone device. Here's the command I used:
./configure \
--host=arm-apple-darwin \
CFLAGS="-arch armv7 \
-isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk" \
CXXFLAGS="-arch armv7 \
-isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk" \
LDFLAGS="-L." \
CC="/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" \
CXX="/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
then make
.
I did the same to compile armv7s
and arm64
architecture. With -arch i386
, I can't use -isysroot
with iPhoneOS.platform
anymore, I guess because iPhoneOS does not support i386, so I changed to iPhoneSimulator.platform
:
./configure \
--host=arm-apple-darwin \
CFLAGS="-arch armv7 \
-isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk" \
CXXFLAGS="-arch armv7 \
-isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk" \
LDFLAGS="-L." \
CC="/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" \
CXX="/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
But it still does not work. There is the same error when I try to compile i386 with iPhoneOS.platform:
checking whether the C compiler works... no
configure: error: C compiler cannot create executables
It seems that iPhoneSimulator doesn't support i386 too?! When I use armv7 lib for iPhone simulator, it said that missing symbol for i386 architecture, so I'm pretty sure iPhone simulator supports i386.
Anyone know how to compile the lib for simulator? Or is there an easier way, importing source code (like this repo) to Xcode then let it build a universal library for all architectures? From now I must build every lib for every arch then combine them using lipo
.
miphoneos-version-min=8.0
(or whatever version you want) to bothCFLAGS
andCXXFLAGS
, then it'll know the target is iOS and let we compile. Make sure to useiPhoneSimulator.platform
in-isysroot
. - kientux