Xcode 4.0.1中与CoreLocation框架有关的未定义符号错误

问题描述

| 我正在研究第一个核心数据教程“位置”。我已经完成了本教程的第一部分,它设置了NavigationController和TableViewController以及向委托添加CoreLocation调用。构建/运行时,出现以下错误
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:/sbin\"
/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
我已经阅读了有关需要链接CoreLocation框架的类似文章,并且据我所知。实际上,它曾经两次在Frameworks目录中。但是,我怀疑这是一个链接器问题,这让我头疼。当针对iOS的MACOS引用时,我会感到困惑。 自从Xcode 4可用以来,我一直在成功使用它。这是我对XCode的第一个打ic,这确实让我有些失落。我很乐意按要求提供更多信息。     

解决方法

        链接到CoreLocation.framework很容易。在XCode4中,单击左列顶部的项目图标(项目导航器)以在主区域中查找“构建阶段”。在“构建阶段”选项卡下,展开“使用库链接二进制文件”选项卡。单击+号以从列表中选择CoreLocation.framework。而已!     ,        右键单击项目图标(xcode),然后选择“显示在文件夹中”,您将找到名称为CoreLocation.framework的框架,只需将其拖放到项目文件列表(xcode)中的Frameworks文件夹中即可。不要忘记将#import和CLLocationManagerDelegate添加到您的.h文件中:-)