Search code examples
iosobjective-cswiftopencvcocoapods

Swift Project With Objective C Wrapper OpenCV


I have just started to use the openCV library and I am trying to get everything set up. I have a swift project and have dowloaded the framework through cocoa pods. I am trying to import the openCV framework in my objective-c file and I keep getting errors. This is my code and the following are the errors.

#import "OpenCVWrapper.h"

//this line causes the errors
#import <opencv2/opencv.hpp>


@implementation OpenCVWrapper
@end

Errors:

enter image description here


Solution

  • After a little digging, I finally found the solution:

    Import any Apple headers AFTER those of OpenCV. So the code should look like this:

    #import <opencv2/opencv.hpp>
    #import "OpenCVWrapper.h"