Reputation: 207
I'm trying to build a Swift framework that includes C++ and OpenCV Framework for iOS
As far as I understand we can't have a bridging header in framework, we have to deal with umbrella header.
My issue is that XCode is not processing C++ file as C++, with that kind of compiler error :
Unknown type name 'class'; did you mean 'Class'?
It also cannot find <iostream>
I currently have my umbrella that is including a objc wrapper for my C++ files.
What is the right way to do it ?
Below my framework umbrella header
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#include <iostream>
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "AGImageDescriptor.h"
#import "AGKitLib.h"
#import "Detector.h"
#import "Observable.h"
#import "Shooter.h"
#import "DocumentDetectedState.hpp"
#import "DocumentMatchState.hpp"
#import "GoodPerspectiveState.hpp"
#import "GoodPositionState.hpp"
#import "InactiveState.h"
#import "ReadyState.hpp"
#import "StartState.h"
#import "State.h"
#import "States.h"
#import "TextDetectedState.hpp"
#import "Tools.hpp"
#import "OpenCVWrapper.h"
#import "UIImage+OpenCV.h"
FOUNDATION_EXPORT double AGKitScanVersionNumber;
FOUNDATION_EXPORT const unsigned char AGKitScanVersionString[];
I am really not an C++ expert nor a C expert so I am probably missing something here.
Upvotes: 3
Views: 1706
Reputation: 4891
The errors your are getting indicate that your umbrella header possibly includes C++ code, directly or indirectly. In fact, I see a lot of .hpp
files, which are probably C++ headers. With Swift code being present in the framework, you cannot do that. All C++ code must be confined to the Objective-C++ wrapper's implementation files (.mm
extension, not .m
used for Objective-C files). Objective-C++ (.mm
) files can used a mixture of C++ and Objective-C code and include the necessary C++ headers.
Here are some questions/answers that might help: Unknown type name 'class'; did you mean 'Class'? and Video processing with OpenCV in IOS Swift project
Upvotes: 2