Using OpenCV under OS X
Using the OpenCV libraries in an Xcode OS X project (opencv 2.2 and later, opencv 2.1 since SVN r3060)
These instructions were written for Xcode 3.1.x and C++
Also tested with Xcode 3.2.x
Create a new Xcode project using the Command Line Utility/Standard Tool template
Select Project -> Edit Project Settings
Select the Build tab
Set Configuration to All Configurations
In the Architectures section, double-click Valid Architectures and remove all the PPC architectures (If you built the libraries as 64-bit only, remove i386 as well)
In the Search Paths section set Header Search Paths to /usr/local/include (/opt/local/include if you used MacPorts)
Close the Project Info window
Select Project -> New Group and create a group called OpenCV Frameworks
With the new group selected, select Project -> Add to Project…
Press the "/" key to get the Go to the folder prompt
Enter /usr/local/lib (/opt/local/lib if you used MacPorts)
Select libopencv_core.dylib, libopencv_highgui.dylib, and any other libraries required by your project.
Click Add
Uncheck Copy Items… and click Add
Now you can include the OpenCV headers, compile, and run your project. The only #include directive you should need is #include <opencv2/opencv.hpp>. It, in turn, includes the rest of the opencv header files. You can alternatively include individual header files with, for example, #include <opencv2/core/core.hpp> or #include <opencv2/highgui/highgui.hpp>.
My comment added:
In some cases, the Xcode compiler doesn't seem to be able to find include files properly.
right-click on the target (ex. opencvproj2) > Get Info > change Header Search Paths field from "/usr/local/include" to "/usr/local/include/**"
Then the errors disappear.