我刚刚升级到xcode 4.0,我不能再部署到iPhone,我得到一个苹果Mach-O链接器错误,它仍然适用于模拟器。

    Ld /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel normal armv7
    cd /Users/yveswheeler/iParcel
    setenv IPHONEOS_DEPLOYMENT_TARGET 3.2
    setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -L/Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos -F/Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos -filelist /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel.LinkFileList -dead_strip -all_load -ObjC -lxml2 -miphoneos-version-min=3.2 -framework UIKit -framework CoreGraphics -framework QuartzCore /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Core.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Network.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Style.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UI.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UICommon.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UINavigator.a -framework AddressBook -lz.1.2.3 -framework Foundation -framework CFNetwork -framework MobileCoreServices -framework SystemConfiguration -framework MessageUI -framework AudioToolbox -o /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel

arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Core.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Network.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Style.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UI.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UICommon.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UINavigator.a: No such file or directory
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 failed with exit code 1

当前回答

我运行xcode 5。在我的情况下,我必须改变我的“部署目标”。它之前设置为3.0,我将其更改为7.0。现在错误消息消失了。要更改“部署目标”,请 请遵循以下步骤:

转到“项目名称”(左上角) 转到“目标”(屏幕中间) 转到“常规” “部署信息” “部署目标”

将其更改为当前iOS版本。 -谢谢。

其他回答

我运行xcode 5。在我的情况下,我必须改变我的“部署目标”。它之前设置为3.0,我将其更改为7.0。现在错误消息消失了。要更改“部署目标”,请 请遵循以下步骤:

转到“项目名称”(左上角) 转到“目标”(屏幕中间) 转到“常规” “部署信息” “部署目标”

将其更改为当前iOS版本。 -谢谢。

我遇到了同样的问题,问题是我不小心在实现文件中导入了.m文件而不是.h文件。

我不小心添加了UITableViewController的同一个子类的两个副本。删除其中一组文件可以清除错误。

我可以通过编辑“库搜索路径”来修复这个错误。

它首先出现是因为我移动了几个文件夹,最终给了我的构建设置两个不同的搜索路径,因为当你链接一个库/框架时,它们会自动添加到你的构建设置中,但它们并不总是被删除。

因此,如果你将一个链接的库/框架移动到不同的目录并重新链接它,你将不得不手动编辑搜索路径。

你可以通过在移动之前删除库/框架来避免这种情况,但我还没有对此进行测试。

I struggled with this for a little while, and in my case it ended up being the Build Setting under Search Paths called FRAMEWORK_SEARCH_PATHS. It helped that I selected the "Levels" button, which seemed to compare my project, target and "Resolved" settings. I saw that my target setting somehow overrode the default of "$(inherited)", and the overridden value was what XCode "resolved" the setting to be. When I removed the override, which in this case specified the 3.2 sdk, the linker errors went away -- as did some recently appeared warnings about any classes where I called post-4.0 methods.

About those warnings -- I never saw them before I added the MessageUI framework for a recent change. I suspect, but don't know for sure, that when I added that framework, XCode tried to do something clever by adding that override to my target. I didn't do it explicitly at any point. The warnings were,for example, about the URLByAppendingPathComponent method of NSURL, which did not appear until sdk 4.0. Prior to adding the MessageUI framework, I never got that warning. And since I removed the override, I no longer get them.