1

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

Nikhil Sridhar
  • 1,410
  • 5
  • 16
  • 33

2 Answers2

1

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"
Nikhil Sridhar
  • 1,410
  • 5
  • 16
  • 33
0

You need to add Bridging Header file and import the objective c file in it. after creating a file you need to add the path of this file into Build settings of project Target. Find Bridging Header in build settings. please refer

https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

  • Please check edit. I have already done what you have said and am trying to use the openCV functionality in my objective-c class. – Nikhil Sridhar Aug 25 '17 at 05:56