链接器命令失败,退出代码为 1(使用 -v 查看调用),在 xcode-Cocoapods 中构建应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37947332/
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
linker command failed with exit code 1 (use -v to see invocation), build app in xcode-Cocoapods
提问by Kamilo Pérz
I am bulding my app in xcode 7, and get the following error:
我在 xcode 7 中构建我的应用程序,并收到以下错误:
ld: library not found for -lAFNetworking clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld:未找到 -lAFNetworking clang 的库:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
Cocoapods was used to load the necessary libraries in the app as follows:
Cocoapods 用于在应用程序中加载必要的库,如下所示:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'myapp' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'AFNetworking', '~> 3.0'
pod 'MBProgressHUD', '~> 0.9.2'
pod 'Reachability', '~> 3.2'
pod 'SDWebImage', '~> 3.8.1'
pod 'ZipArchive', '~> 1.4.0'
pod 'JDFTooltips', '~> 1.1'
end
what should I do?
我该怎么办?
回答by Ptah
I had similar problem.
我有类似的问题。
1) Clean DerivedData (~/Library/Developer/Xcode/DerivedData)
1) 清理派生数据 (~/Library/Developer/Xcode/DerivedData)
2) Product -> Clean -> Rebuild
2) 产品 -> 清洁 -> 重建
3) Open Pods Targets and set Build Active Architecture Only
- NO
3) 打开 Pods 目标并设置Build Active Architecture Only
- 否
回答by Lucas
First of all, I would check to see if your podfile is in the same directory as your target.
首先,我会检查您的 podfile 是否与目标位于同一目录中。
If it is, delete the podfile.lock and the pods folder. (Leave the podfile alone.)
如果是,请删除 podfile.lock 和 pods 文件夹。(别管 podfile。)
Clean the project (CMD+SHIFT+K). This may be unnecessary, but its usually worth doing just to be sure.
清理项目(CMD+SHIFT+K)。这可能是不必要的,但它通常值得做只是为了确定。
Then, do a pod install.
然后,进行 pod 安装。
See if there are any warnings (yellow, not red text) in the terminal. Sometimes these warnings will prevent your project from building, and sometimes they won't. If your project won't build, and you do have warnings, try to fix them.
查看终端中是否有任何警告(黄色,而不是红色文本)。有时这些警告会阻止您的项目构建,有时则不会。如果您的项目无法构建,并且您确实收到警告,请尝试修复它们。
For example, there is a warning that mentions setting the build paths or something to $(inherited). I had one project that built fine with this warning, and another that required me to fix it.
例如,有一个警告提到将构建路径或其他内容设置为 $(inherited)。我有一个项目在此警告下构建良好,另一个项目需要我修复它。
I'm not guaranteeing this will work, but I think its a good first step.
我不保证这会奏效,但我认为这是一个很好的第一步。
回答by Jose Llausas
Did you change the name of your project?
您是否更改了项目名称?
Check this answer: ld: file not found: linker command failed with exit code 1 (use -v to see invocation)
回答by ErikBrandsma
This also happened to me a lot, but i solved it by deleting the DerivedDatafolder of the project and related projects that was having problems, you can see how to simply do this by looking at this answer:
这也发生在我身上很多,但我通过删除项目的DerivedData文件夹和出现问题的相关项目来解决它,您可以通过查看以下答案来了解如何简单地执行此操作:
https://stackoverflow.com/a/37990186/3975501
https://stackoverflow.com/a/37990186/3975501
Also this poses no risk to your application as DerivedData is just a folder that Xcode uses to reduce compiling time. If it's deleted Xcode will simply recreate it.
此外,这不会给您的应用程序带来任何风险,因为 DerivedData 只是 Xcode 用来减少编译时间的文件夹。如果它被删除,Xcode 将简单地重新创建它。
回答by Hany Sakr
I faced the same error while writing C using Xcode 8, The issue was there was a duplicate main method in two different files.
我在使用 Xcode 8 编写 C 时遇到了同样的错误,问题是在两个不同的文件中有一个重复的 main 方法。
So, I commented one of them, then the error disappeared and the application started to compile successfully.
所以,我评论了其中一个,然后错误消失了,应用程序开始成功编译。