2

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

3
  • Just import openCV .h files in Bridging-Header.h, it doesn't work? Commented Aug 25, 2017 at 5:39
  • Please check edit. I have already done what you have said and am trying to use the openCV functionality in my objective-c class. Commented Aug 25, 2017 at 5:56
  • Please check stackoverflow.com/questions/24206732/…, hope it will helpful Commented Aug 25, 2017 at 8:17

3 Answers 3

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"
Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

Please check edit. I have already done what you have said and am trying to use the openCV functionality in my objective-c class.
0

I also faced same problem. I solved it by just changing my Helper.m file to Helper.mm

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.