Undefined symbols error in Xcode 4.0.1 concerning CoreLocation framework
I'm working through the first Core Data tutorial, "Locations". I've completed the first part of the tutorial, which sets up the NavigationController and TableViewController as well as adding CoreLocation calls to the delegate. When I build/run, I get the following error:
Ld /Users/parradoxx/Library/Developer/Xcode/DerivedData/Locations-dbbkuqswxbvwszevbplxgtcndmeo/Build/Products/Debug-iphonesimulator/Locations.app/Locations normal i386
cd /Users/parradoxx/Projects/Locations
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbi开发者_JS百科n"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/parradoxx/Library/Developer/Xcode/DerivedData/Locations-dbbkuqswxbvwszevbplxgtcndmeo/Build/Products/Debug-iphonesimulator -F/Users/parradoxx/Library/Developer/Xcode/DerivedData/Locations-dbbkuqswxbvwszevbplxgtcndmeo/Build/Products/Debug-iphonesimulator -F/Users/parradoxx/Projects/Locations -filelist /Users/parradoxx/Library/Developer/Xcode/DerivedData/Locations-dbbkuqswxbvwszevbplxgtcndmeo/Build/Intermediates/Locations.build/Debug-iphonesimulator/Locations.build/Objects-normal/i386/Locations.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework CoreLocation -framework UIKit -framework Foundation -framework CoreGraphics -framework CoreData -o /Users/parradoxx/Library/Developer/Xcode/DerivedData/Locations-dbbkuqswxbvwszevbplxgtcndmeo/Build/Products/Debug-iphonesimulator/Locations.app/Locations
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CLLocationManager", referenced from:
objc-class-ref in RootViewController.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
I've read similar posts about needing to link the CoreLocation framework, and I have -- to the best of my knowledge. In fact, it was in the Frameworks directory twice for awhile. However, I suspect its a linker problem, and this gets over my head. Where I see the confusion are the references to MACOS when this is targeted for iOS.
I've been using Xcode 4 successfully since it became available. This is my first hiccup with XCode and it does leave me a bit lost. I'm happy to provide further information as requested.
Linking to the CoreLocation.framework is easy. In XCode4, click on your project icon in the top of the left column (project navigator) to look up the Build Phases in the main area. Below the Build Phases tab, expand the Link Binary With Libraries tab. Click on the + sign to pick the CoreLocation.framework from a list. That's it!
RightClick on your project icon (xcode) then select show in folder, You'll find a framework by the name CoreLocation.framework, just drag and drop this to Frameworks folder in your project files list (xcode). Don't forget to add #import and CLLocationManagerDelegate to your .h file :-)
精彩评论