Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV iOS - Expected identifier (MACRO)

Getting error from "opencv2.framework". Just a new project contained "opencv2.framework" not running.

My Steps:

  1. download latest opencv2.framework
  2. add required frameworks
  3. declare .pch file stuff
  4. changed .m file -> .mm

Am I missing something?

enter image description here

#ifndef PrefixHeader_pch
#define PrefixHeader_pch

#import <Availability.h>

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

#endif /* PrefixHeader_pch */

enter image description here

like image 753
Ofir Malachi Avatar asked Feb 10 '26 13:02

Ofir Malachi


1 Answers

Line 46 says it all: You have to put opencv.hpp before any Apple's headers. In PrefixHeader.pch move

#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif

up and before

#import <Availability.h>
like image 196
Quang Hoang Avatar answered Feb 15 '26 07:02

Quang Hoang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!