After enabling bit code in Xcode 7, I couldn’t build .a file with embed-bitcode. Same problem for the zbar library, too. So, I cannot use my own library with a .a file or cannot use the zbar for production. After searching from google, I found a way to build. We need to use the command line with
I wrote the
build.sh like following and same folder with myproject.xcodeproj
folder="Release" project_name="mycustomlib" lib_name="libmycustom" name_simulator=$lib_name"_simulator" name_device=$lib_name"_device" xcodebuild OTHER_CFLAGS="-fembed-bitcode" -target $project_name build xcodebuild OTHER_CFLAGS="-fembed-bitcode" -sdk iphonesimulator -target $project_name build rm -r build/Production-SDK cp -r build/$folder-iphoneos build/Production-SDK cp build/$folder-iphonesimulator/$lib_name.a build/Production-SDK/$name_simulator.a mv build/Production-SDK/$lib_name.a build/Production-SDK/$name_device.a cd build/Production-SDK/ lipo -create $name_simulator.a $name_device.a -output $lib_name.a rm $name_device.a rm $name_simulator.a file $lib_name.a open .
In the build.sh ,
folder is your release folder name. zbar is using Distribution-iphoneos and Distribution-iphonesimulator .
If you using your own, it may be Release-iphoneos and Release-iphonesimulator.
lib_name is your .a library name. In Zbar, it’s using libzbar .
project_name is your traget to build. Sometime ,
project_name is different in the project.
After chasing this two, you can run in terminal like
Need to wait until finishing the build and then it will show your lib.a file. In the terminal, you can check, it’s showing what platform is supporting.
If it doesn’t support i386,x86_64,armv7, arm64, you need to open your project. Go to Build Settings -> Valid Architectures. Add all architectures like following
Don’t forget to change Build Active Architecture Only to NO