5
votes

I've been using Objective-C mixed with C++ in Qt without any issues; using .mm files where required.

After upgrading my build machine to Mavericks, I initially noticed that the framework headers were missing, so installed the XCode command line tools, which fixed the issue.

Now, I'm getting a problem compiling Objective-C files with errors complaining about code in the frameworks. For example: -

System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSUserNotification.h:16:44: error: missing ',' between enumerators NSUserNotificationActivationTypeReplied NS_AVAILABLE(10_9, NA) = 3

And

/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSApplication.h:58:34: error: expected ';' after top level declarator typedef NSInteger NSModalResponse NS_AVAILABLE_MAC(10_9);

I've upgraded to Qt 5.2.1, but the issues remain and it's coming from including standard framework headers; in this case: -

#import <NSUserNotification.h>
#import <NSApplication.h>

Can someone please explain what's changed in Mavericks and how I can fix these errors?

1
All the error messages are here: pastebin.com/HS7iTc3h - TheDarkKnight
Ah, ok. That's here, thanks: pastebin.com/FsZQ2y4M - TheDarkKnight
The minimal header and mm files are here: pastebin.com/7CwJfbez - TheDarkKnight
You absolutely should not be adding any framework includes. You're importing your frameworks not according to Apple's documentation - Kuba hasn't forgotten Monica

1 Answers

6
votes

You're supposed to include the frameworks as Framework/Header.h. It seems that you've added some unnecessary includes to your project file.

The following works for me:

#project.pro
TEMPLATE = app

LIBS += -framework AppKit -framework Foundation

OBJECTIVE_SOURCES = main.mm
//main.mm
#import <Foundation/NSUserNotification.h>
#import <AppKit/NSApplication.h>
#include <QCoreApplication>

int main(int argc, char ** argv)
{
   QCoreApplication a(argc, argv);
   NSApplication * app = [NSApplication sharedApplication];
   return 0;
}