Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C in Qt with Mavericks

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?

like image 345
TheDarkKnight Avatar asked Mar 17 '14 14:03

TheDarkKnight


1 Answers

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;
}
like image 86
Kuba hasn't forgotten Monica Avatar answered Sep 23 '22 01:09

Kuba hasn't forgotten Monica