简体   繁体   中英

Could not build module 'opencv2' , when using OpenCV in Swift Project

I have added opencv framework through cocoapods . I added required frameworks to Linked Frameworks and Libraries as well.

As, I am using Swift. So, I made a bridging header with " Wrapper " NSObject in Objective C. Problem is that when I try to import these in Wrapper.h , it gives me error

#import <opencv2/opencv.hpp>
#import <opencv2/imgcodecs/ios.h>

Error is:

Could not build module 'opencv2'

Where as if I import them in Wrapper.mm they work fine. Kindly tell me how to use them in header file. As I need to call a few variables from header file.

When bridging header files to Swift, the files have to be pure Objective-C++. So you cannot include any opencv headers in Wrapper.h , they have to go in Wrapper.mm . For more detail how to write and use a wrapper, see my answer here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM