Question

Possible Duplicate:
symbol(s) not found in XCode, Cocoa application

Below is the error information

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)

below is the code. Should I include more header?

#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;
}
Was it helpful?

Solution

correctly link against AppKit.framework, headers dont contain the 'real' code

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top