Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
184 views
Welcome To Ask or Share your Answers For Others

1 Answer

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;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...