当我使用NSPasteboard时,我遇到了架构x86_64的未定义符号

时间:2012-12-21 16:37:32

标签: objective-c cocoa nspasteboard

  

可能重复:
  symbol(s) not found in XCode, Cocoa application

以下是错误信息

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

1 个答案:

答案 0 :(得分:3)

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