I can’t get CocoaServer to build. I’m running OS X 10.7.3, Xcode 4.3. No doubt it’s something simple I’m leaving out. But I can’t get around this link error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_HTTPServer", referenced from:
objc-class-ref in CocoaServerAppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I wonder if someone can check to see if this happens to them. You don’t have to re-do the whole project. It’s 2 lines of code, or simply copy and paste. It’ll take someone two minutes, tops, and any insight would be sorely appreciated.
Make a new project (Mac OS X Cocoa Application), call it CocoaServer (just to match my code below). You can leave ARC on or turn it off. It doesn’t matter.
Drag the HTTPServer and TCPServer .h & .m files into the project and check the box that says to copy them. [As you recall, we get these files by downloading the code at http://www.bignerdranch.com/solutions/iOSProgramming.zip and looking in the solutions directory for the CocoaServer project.] You should now have the following files in the project:
In CocoaServerAppDelegate.h, add
so that it looks like this:
@interface CocoaServerAppDelegate : NSObject
@property (assign) IBOutlet NSWindow *window;
- In CocoaServerAppDelegate.m, simply alloc/init an HTTPServer:
@synthesize window = _window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
HTTPServer *server = [[HTTPServer alloc] init];
The sample code compiles just fine. But my code won’t link. What am I doing wrong?