以下是错误信息
Undefined symbols for architecture x86_64:
"_NSPasteboardTypeString", referenced from:
_main in main.o
"_OBJC_CLASS_$_NSPasteboard", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
下面是代码。我应该包含更多标题吗?
#import <Foundation/Foundation.h>
#import <AppKit/NSPasteboard.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSString *content = [pasteboard stringForType:NSPasteboardTypeString];
NSLog(@"%@", content);
}
return 0;
}
答案 0 :(得分:3)
正确链接AppKit.framework,标题不包含“真实”代码