When I tried to compile my XCode project with OpenCV 2.4 iOS using XCode 7 + iOS SDK 9, XCode complained that
ld: \'opencv2.framework/opencv2(alloc.
After some search and trial, I figured out a way to compile OpenCV iOS from the source with Bitcode. A compiled binary is also provided here: [v3.0] [v2.4]. [Disclaimer: I am not responsible for the integrity of the compiled binary. Use at your own risk.]
The steps of compilation is basically the same as the official document, with only one extra step.
Download the code with git:
cd ~/
git clone https://github.com/Itseez/opencv.git
Make symbolic link for Xcode to let OpenCV build scripts find the compiler, header files etc.
cd /
sudo ln -s /Applications/Xcode.app/Contents/Developer Developer
[Key Step] Change the compilation script to add the extra option for Bitcode: edit ~/, and locate the line containing -DCMAKE_C_FLAGS. Add a flag of -fembed-bitcode. For example, in the source I got, it's line 55, and will look like
"-DCMAKE_C_FLAGS=\"-Wno-implicit-function-declaration -fembed-bitcode\" " +
after the change. [ref]
Build OpenCV framework:
cd ~/
python opencv/platforms/ios/build_framework.py ios
If everything’s fine, a few minutes later you will get ~/. You can add this framework to your Xcode projects.
P.S. Ask a question, even when you already know the answer is encouraged according to this post on Meta Stackchange.