Granit
Granit

Reputation: 1281

Xcode 8 (Swift): core.hpp header must be compiled as C++

I am using the OpenCV iOS Framework in a project. I followed the necessary steps to include the framework into the project.

The Project is written using Swift 3.

One of my classes that contains the core functionality of the App is written in Objective-C++. I included the header of the class in my Bridge-header file but when trying to run the project I get the following error:

error core.hpp header must be compiled as C++

After researching online and on SO, the most common solution presented was to create a Wrapper class that would be imported in the bridge header. However, after following this article I face the same problem.

The Header file of my class looks like this:

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#define IMAGE_CLASS UIImage
#elif TARGET_OS_MAC
#import <Cocoa/Cocoa.h>
#define IMAGE_CLASS NSImage
#endif

#import <AGGeometryKit/AGKQuad.h>

#import <stdio.h>
#import <opencv2/opencv.hpp>

#import <Foundation/Foundation.h>

typedef void (^DebugBlock)(cv::Mat current_image, std::string current_image_name);

@interface ImageScanner : NSObject

/**
 *  Singleton for access to the scanner.
 *
 *  @return Shared scanner.
 */
+ (instancetype)sharedScanner;

Does anyone have an idea what I might be missing?

Thank you in advance! G.

Upvotes: 0

Views: 1846

Answers (1)

Abdul Waheed
Abdul Waheed

Reputation: 894

had the same problem.. solved by importing any file that use openCV in the wrapperClass.mm file ...

SO Answer here

Upvotes: 1

Related Questions