在Xcode中构建项目时出现以下错误:
ld:找不到文件/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events clang:错误:链接器命令失败,退出代码为1(使用 - v看看调用)
过去一小时我一直坚持这个错误..任何解决方案?代码在 iOS 7 和 xCode 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
10 回答
您可能会收到此错误,因为您重命名了项目并且无法找到
Tests
. 这很容易解决:像这样在Xcode中解决它:
从项目导航器中选择项目 .
在目标下选择
[Your project's Tests]
在
General
标签下,从下拉列表中更改Host Application
构建并运行 .
这个问题发生在我身上,因为我重命名了我的项目,测试再也找不到了 .
问题是在重命名产品后,其测试目标仍在寻找以前的应用名称 .
选择“测试”目标,然后在“构建设置”中,按以下方式修改TestHost值以对应新产品名称:
我通过重命名产品解决了这个问题 .
在Application的目标中,选择Build Settings .
在“打包”选项下,您必须将产品重命名为错误中显示的名称 .
它解决了我的问题,代码开始编译 . 我的测试用例也在执行中 .
我有一个类似的问题 - 这是因为我使用Cocoapods并打开了.xcodeproj文件而不是.xcworkspace文件... doh!
您是否尝试清理派生数据?
尝试删除“Social_EventsTests”目标 .
Goto构建名为PuzzleGameTests的测试设置 .
转到测试设置,写$(BUILT_PRODUCTS_DIR)/PuzzleGame.app/PuzzleGame
清洁和建造
注意:PuzzleGame是我项目的新名称(产品名称) . RandomNumber是我的项目的旧名称(产品名称) .
我遇到了“未找到框架”的问题 . 这是在重命名我的项目之后 .
转到项目设置,选择目标(而不是项目) . 在“常规”选项卡中,找到"Linked frameworks and libraries",然后删除旧名称 .
我在添加
FBSDKCoreKit.framework
时遇到了类似的问题,解决方法是:如果已添加
frameworks
,则使用选项remove all references
将其删除 .在
group
中直接拖放frameworks
,以便将其放入项目中 .之后不要重新拖动或更改其位置
注意:当我们在xcode中拖放框架时,它会自动在
<yourproject> -> Targets -> <yourproject> -> Search Paths -> Framework Search Paths
下设置框架搜索路径 . 一旦我们重新定位框架,Framework Search Paths
变为空,它将导致linker error , framework not found
.当我将单元测试目标添加到现有项目时遇到类似的问题 . 得到各种各样的错误 . 不得不通过一些循环来让它最终运行 . 在下面列出它们
确保您在测试目标的 Headers 搜索路径下的条目与主项目文件夹中的 Headers 搜索路径的条目匹配
如果您使用的是pod,则可能会出现“No Module found Firebase”等错误 . 为此,只需将以下代码行添加到您的pod文件并运行pod install
目标'YourProjectNameTests'做
继承! :search_paths
#Pods用于测试
结束
如果你也找不到Bridging头文件错误,就像我确实你在Swift编译代码一般的Build设置中为你的测试目标添加相同的
此外,您必须按照@Jose Llausas提到的步骤进行操作