1.Open Xcode, choose New -> New Project -> Command Line Tool
2.Name it and select C++ for type
3.Click on your project from the left menu. Click the build settings tab from the top. Filter all. Scroll to Search Paths. Under header search paths, for debug and release, set the path to /usr/local/include. Under library search paths, set the path to $(PROJECT_DIR). Finally, check if C++ standard library is libstdc++ or not, if not, change it to this!
4.Click on your project from the left menu. File->New->New Group, Name the group OpenCV Frameworks.
5.Select the folder (group) you just labeled, OpenCV Frameworks in the left menu. Go to File -> add Files, Type /, which will allow you to manually go to a folder. Go to -> /usr/local/lib
6.Select both of these files, libopencv_core.dylib, libopencv_highgui.dylib, and click Add. (you may need to add other library files from this folder to run other code.)
7.You must include this line of code in the beginning of your main.cpp file:#include <opencv2/opencv.hpp>