-1

可能重复:
在 XCode、Cocoa 应用程序中找不到符号

下面是错误信息

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

1 回答 1

3

正确链接到 AppKit.framework,标头不包含“真实”代码

于 2012-12-21T16:39:05.047 回答