Objective-C在Qt与小牛 [英] Objective-C in Qt with Mavericks
问题描述
我一直在使用Objective-C混合C ++在Qt没有任何问题;在需要时使用.mm文件。
I've been using Objective-C mixed with C++ in Qt without any issues; using .mm files where required.
将构建机器升级到Mavericks后,我最初注意到框架头文件丢失,因此安装了XCode命令行工具问题。
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.
现在,我编译Objective-C文件时遇到错误,抱怨框架中的代码。例如:
Now, I'm getting a problem compiling Objective-C files with errors complaining about code in the frameworks. For example: -
系统/库/ Frameworks / Foundation.framework /版本/ C / Headers / NSUserNotification.h:16:44:错误:在枚举器之间缺少','
NSUserNotificationActivationTypeReplied NS_AVAILABLE(10_9,NA)= 3
System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSUserNotification.h:16:44: error: missing ',' between enumerators NSUserNotificationActivationTypeReplied NS_AVAILABLE(10_9, NA) = 3
b
$ b
And
/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSApplication.h:58:34:错误:expected';'after top级别声明者
typedef NSInteger NSModalResponse NS_AVAILABLE_MAC(10_9);
/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);
我升级到Qt 5.2.1,保留,它来自包括标准框架标题;在这种情况下: -
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>
有人可以解释一下Mavericks的变化,以及如何解决这些错误?
Can someone please explain what's changed in Mavericks and how I can fix these errors?
推荐答案
您应该包括框架作为Framework / Header.h 。
以下作品适用于我:
#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;
}
这篇关于Objective-C在Qt与小牛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!