Setting up an iOS OpenCV project with CocoaPods
To start using OpenCV in iOS, we must import the library compiled for iOS devices. This is easily done with CocoaPods, which is a vast repository of external packages for iOS and macOS with a convenient command-line package manager utility called pod
.
We begin by creating an empty Xcode project for iOS, with the "Single View App" template. Make sure to select a Swift project, and not an Objective-C one. The Objective-C++ code we will see will be added later.
After the project in initialized in a certain directory, we execute the pod init
command in the terminal within that directory. This will create a new file called Podfile
in the directory. We need to edit the file to look like the following:
# Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'OpenCV Stitcher' do use_frameworks! # Pods for OpenCV Stitcher pod 'OpenCV2', '4.0.0.beta' end
Essentially, just adding pod 'OpenCV2', '4.0.0'
...