-1

I'm currently trying to implement the PIMPL-Idiom to encapsulate Objective-C functionality in a C++ class in Qt. My pro file looks as it follows:

QT += core gui
TARGET = testProject
TEMPLATE = app
SOURCES += main.cpp Helper.cpp
HEADERS += HelperInterface.h Helper.h

OBJECTIVE_SOURCES += ObjCHelper.mm
OBJECTIVE_HEADERS += ObjCHelper.h

The ObjCHelper.h is the objective-C header

#import "HelperInterface.h"

@interface ObjCHelper : NSObject { int someVar }
- (int) doSomething():(void *)param;
@end

The ObjCHelper.mm

#import "ObjCHelper.h"

@implementation ObjCHelper
MyClassImpl::MyClassImpl() : self(NULL) { }
MyClassImpl::~MyClassImpl() {
    [(id)self dealloc];
}
void MyClassImpl::init()
{
    self = [[ObjCHelper alloc] init];
}
//...
@end

The class MyClassImpl is defined in HelperInterface.


When i try to compile this project i receive the following errors:

cannot find interface declaration for 'NSObject', superclass of 'ObjCHelper'
@interface ObjCHelper : NSObject
~~~~~~~~~~~~~~~~~~~~~   ^

It seems to me like Qt is treating the Objective-C header file ObjCHelper.h as a normal c++ header file! Why is that so?

The header file ObjCHelper.h isn't included anywhere else than in ObjCHelper.mm

ParkerHalo
  • 4,104
  • 9
  • 25
  • 47

1 Answers1

1

Might be an instance of https://bugreports.qt.io/browse/QTBUG-36575 , fixed by https://codereview.qt-project.org/#/c/77117/ in Qt 5.6.

peppe
  • 19,728
  • 3
  • 47
  • 65