ios ld:找不到文件:链接器命令失败,退出代码为 1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26665196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ld: file not found: linker command failed with exit code 1
提问by Jose Llausas
I've got the following error when building the project in Xcode:
在 Xcode 中构建项目时出现以下错误:
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)
ld:找不到文件
/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
I'm stuck with this error for the past hour.. Any solutions? Code worked fine in iOS 7and xCode 5.0. Now for iOS8it gives me this error.
过去一个小时我一直被这个错误困扰..有什么解决办法吗?代码在iOS 7和xCode 5.0 中运行良好。现在对于iOS8,它给了我这个错误。
Using frameworks:
使用框架:
- CoreTelephony
- Mapkit
- Facebook.SDK v3.20
- Foundation
- CoreGraphics
- UIKit Framework
- 核心电话
- 地图包
- Facebook.SDK v3.20
- 基础
- 核心图形
- UIKit 框架
FULL ERROR:
完全错误:
<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
回答by Jose Llausas
You might be getting this error because you renamed your project and Tests
cannot be found anymore. This is easy to fix:
您可能会收到此错误,因为您重命名了项目并且Tests
再也找不到了。这很容易解决:
Solve it in Xcode like this:
像这样在Xcode中解决它:
- Select your project from the project navigator.
- Select
[Your project's Tests]
under targets - Under
General
tab change theHost Application
from the drop down - Build and run.
- 从项目导航器中选择您的项目。
[Your project's Tests]
在目标下选择- 在
General
选项卡下Host Application
从下拉列表中更改 - 构建并运行。
This problem happened to me because I renamed my project and the tests could't find it anymore.
这个问题发生在我身上,因为我重命名了我的项目并且测试再也找不到它了。
回答by Vladimir Afinello
The problem is that after renaming the product its Tests target is still looking for the previous app name.
问题是在重命名产品后,它的测试目标仍在寻找以前的应用程序名称。
Select your Tests target and then in Build Settings modify the TestHost values to correspond your new product name in the following way:
选择您的测试目标,然后在 Build Settings 中修改 TestHost 值以按以下方式对应您的新产品名称:
$(BUILT_PRODUCTS_DIR)/YourNewProductName.app/YourNewProductName
回答by Darren
I had a similar problem -- it's because I was using Cocoapods and had opened the .xcodeproj file instead of the .xcworkspace file... doh!
我遇到了类似的问题——这是因为我使用的是 Cocoapods 并且打开了 .xcodeproj 文件而不是 .xcworkspace 文件......哦!
回答by Selvin
I have solved it by renaming the product.
我已经通过重命名产品解决了这个问题。
In the Application's target choose Build Settings.
在应用程序的目标中选择构建设置。
Under the Packaging options, you have to rename your product to the name thats shown in the error.
在包装选项下,您必须将产品重命名为错误中显示的名称。
It solved my problem and the code started compiling. My test cases are also executing.
它解决了我的问题,代码开始编译。我的测试用例也在执行。
回答by thatzprem
Did you try cleaning up your derived data?
您是否尝试清理派生数据?
Xcode5->Organizer->Projects->Select your project->Delete the derived data.
回答by vahotm
Try to remove "Social_EventsTests" target.
尝试删除“Social_EventsTests”目标。
回答by pkc456
- Goto Build settings of your tests named PuzzleGameTests.
- Go to Testing settings, write $(BUILT_PRODUCTS_DIR)/PuzzleGame.app/PuzzleGame
- Clean and build
- 转到名为 PuzzleGameTests 的测试的构建设置。
- 转到测试设置,写入 $(BUILT_PRODUCTS_DIR)/PuzzleGame.app/PuzzleGame
- 清洁和构建
Note: PuzzleGame is new name of my project(product name). RandomNumber is old name of my project(product name).
注意:PuzzleGame 是我的项目的新名称(产品名称)。RandomNumber 是我项目的旧名称(产品名称)。
回答by Vlad Pulichev
I had issue with "framework not found". It was after renaming my project.
我遇到了“找不到框架”的问题。这是在重命名我的项目之后。
Go to Project settings, select the target (notthe project). In the General tab, find "Linked frameworks and libraries", and delete?the old name.
转到项目设置,选择目标(不是项目)。在“常规”选项卡中,找到“链接的框架和库”,然后删除旧名称。
回答by Dashrath
I encountered similar problem while adding FBSDKCoreKit.framework
and solution was :
我在添加时遇到了类似的问题FBSDKCoreKit.framework
,解决方案是:
- If
frameworks
already added then remove it with optionremove all references
. - Drag & drop
frameworks
straight in thegroup
you want it to put in project. - do not re-drag or change its location afterwords
- 如果
frameworks
已添加,则使用 option 将其删除remove all references
。 - 拖放
frameworks
直接在group
你想让它放在项目。 - 后记不要重新拖动或更改其位置
Note: When we drag & drop frameworks in xcode it automatically set framework search path under <yourproject> -> Targets -> <yourproject> -> Search Paths -> Framework Search Paths
.
once we relocate the frameworks, the Framework Search Paths
becomes empty and it results in linker error , framework not found
.
注意:当我们在 xcode 中拖放框架时,它会自动在<yourproject> -> Targets -> <yourproject> -> Search Paths -> Framework Search Paths
. 一旦我们重新定位框架, 就Framework Search Paths
变成空的并导致linker error , framework not found
.
回答by SaketGupte
Had similar kind of problem when I added unit test target to my existing project. Got all sorts of error. Had to run through some loops to get it finally running. Listing them below
当我将单元测试目标添加到现有项目时遇到了类似的问题。得到各种错误。不得不运行一些循环才能让它最终运行。在下面列出它们
Make sure your entry under Header search path for test target matches that for Header Search Path in your main project folder
If you are using pods you might run in some error such 'No Module found Firebase'. For this simply add the following lines of code to your pod file and run pod install
target 'YourProjectNameTests' do
inherit! :search_paths
# Pods for testing
end
If you also get Bridging header file not found error like I did make sure you add the same for your test target in Build settings under Swift compile code general
Also you will have to follow the steps mentioned by @Jose Llausas
确保测试目标的标题搜索路径下的条目与主项目文件夹中的标题搜索路径匹配
如果您使用的是 pod,您可能会遇到一些错误,例如“未找到模块 Firebase”。为此,只需将以下代码行添加到 pod 文件并运行 pod install
目标 'YourProjectNameTests' 做
继承!:search_paths
# 用于测试的 Pod
结尾
如果你也像我一样得到 Bridging header file not found 错误,请确保在 Swift compile code general 下的 Build settings 中为你的测试目标添加相同的内容
此外,您还必须遵循@Jose Llausas 提到的步骤