ld:找不到文件:链接器命令失败,退出代码为1

53 xcode linker objective-c ios

在Xcode中构建项目时出现以下错误:

ld:找不到文件

/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

过去一小时我一直坚持这个错误..任何解决方案?代码在iOS 7xCode 5.0中运行良好.现在对于iOS8,它给了我这个错误.

使用框架:

  • CoreTelephony
  • Mapkit
  • Facebook.SDK v3.20
  • 基础
  • CoreGraphics中
  • UIKit框架

完全错误:

<pre>
Ld /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests normal arm64
    cd /Users/MacBookPro/Desktop/Social_Events/Social_Events/Social_Events
    export IPHONEOS_DEPLOYMENT_TARGET=7.1
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
</pre>

>/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -L/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos -F/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/Developer/Library/Frameworks -filelist /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests.LinkFileList -dead_strip -bundle_loader /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events -framework XCTest -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=7.1 -framework XCTest -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests_dependency_info.dat -o /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests

>ld: file not found: /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events
clang: error: linker command failed with exit code 1 (use -v to see invocation)

>(null): File not found: /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events
Run Code Online (Sandbox Code Playgroud)

Jos*_*sas 169

您可能会收到此错误,因为您重命名了项目并且Tests无法再找到它.这很容易解决:

像这样在Xcode中解决它:

  1. 从项目导航器中选择项目.
  2. [Your project's Tests]在目标下选择
  3. General标签下更改Host Application下拉列表
  4. 建立并运行.

截图

这个问题发生在我身上,因为我重命名了我的项目,测试再也找不到了.

  • 谢谢.在我重命名我的项目并且测试无法运行之后,这帮助了我. (6认同)

Vla*_*llo 29

问题是在重命名产品后,其测试目标仍在寻找以前的应用名称.

选择"测试"目标,然后在"构建设置"中,按以下方式修改TestHost值以对应新产品名称:

$(BUILT_PRODUCTS_DIR)/YourNewProductName.app/YourNewProductName
Run Code Online (Sandbox Code Playgroud)

  • 是的,谢谢,这解决了这个问题. (2认同)

Sel*_*vin 13

我通过重命名产品解决了这个问题.

在Application的目标中,选择Build Settings.

在"打包"选项下,您必须将产品重命名为错误中显示的名称.

它解决了我的问题,代码开始编译.我的测试用例也在执行中.

  • @IbadUrRahman为了解决这个问题,您必须将产品名称和错误中显示的名称保持一致.但是如果要更改应用程序的显示名称,可以通过重命名`bundle display name`来实现.信息plist. (2认同)

Dar*_*ren 13

我有一个类似的问题 - 这是因为我使用Cocoapods并打开.xcodeproj文件而不是.xcworkspace文件... doh!