-1

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;
}
Community
  • 1
  • 1
Cuero
  • 1,169
  • 4
  • 21
  • 42
  • Oh, am I missing something, or is this really not related to Xcode? –  Dec 21 '12 at 16:41
  • possible duplicate of [symbol(s) not found in XCode, Cocoa application](http://stackoverflow.com/questions/1159227/symbols-not-found-in-xcode-cocoa-application) and [symbols not found for architecture i386](http://stackoverflow.com/questions/4839981/symbols-not-found-for-architecture-i386) and **loads** of similar questions. –  Dec 21 '12 at 16:43
  • Not that this would solve this problem, but you should not import specific classes' headers. You should import each framework's top-level header—the one with the same name as the framework—only. – Peter Hosey Dec 22 '12 at 03:02

1 Answers1

3

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

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135