ios 链接器命令失败,退出代码为 1(使用 -v 查看调用)、Xcode 8、Swift 3

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43795385/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:06:39  来源:igfitidea点击:

Linker Command failed with exit code 1 (use -v to see invocation), Xcode 8, Swift 3

iosobjective-cxcodexcode8carthage

提问by Jake Dobson

I can't get rid of this error!

我无法摆脱这个错误!

I have tried all sorts of things like clearing Derived Data(Preferences->Locations->click gray arrow to open Derived Data folder in Finder->right-click, move to trash), cleaning the project(CMD+Shift+K or Product->Clean), updating carthage and dependencies, checked other answers on StackOverflow (mostly adjustments in Build Settings/Phases), and recloned the app from github, etc.

我尝试了各种方法,例如清除派生数据(首选项-> 位置-> 单击灰色箭头以在 Finder 中打开派生数据文件夹-> 右键单击​​,移至垃圾箱)、清理项目(CMD+Shift+K 或 Product -> Clean),更新 carthage 和依赖项,检查 StackOverflow 上的其他答案(主要是在 Build Settings/Phases 中进行调整),并从 github 重新克隆应用程序等。

The same project works on my collaborators computers..

同一个项目适用于我的合作者计算机。

EDIT: From the current top-rated answer, I was able to debug a little further...I am still not sure how to fix though. It looks like I have something in the project twice? I looked and can't find anything showing up twice!

编辑:从当前评分最高的答案来看,我能够进一步调试......但我仍然不确定如何修复。看起来我在项目中有两次?我看了两次都找不到任何东西!

Here's a picture of the log:

这是日志的图片:

回答by umairqureshi_6

i was facing same issue today in xcode 8 version 8.3.2

我今天在 xcode 8 版本 8.3.2 中遇到了同样的问题

right click on issue --> reveal in log

右键单击问题 --> 在日志中显示

enter image description here

在此处输入图片说明

then you are able to check what is causing that issue

然后你就可以检查是什么导致了这个问题

enter image description here

在此处输入图片说明

回答by Aashish

Maybe you installed a pod fileand you are still trying to build from the .xcodeprojfile instead of .xcworkspace

也许您安装了一个pod 文件,但您仍在尝试从该.xcodeproj文件进行构建,而不是.xcworkspace

回答by Charles Harring

the only thing that worked for me was to run pod deintegrateand pod install

唯一对我有用的是跑步pod deintegratepod install

回答by Francisco Perez

did you try a clean? cmd + shift + k

你试过干净吗?cmd + shift + k

回答by Jake Dobson

Okay...So here is what solved my problem...

好的......所以这就是解决我的问题......

in App Delegate File:

在应用程序委托文件中:

#import "AppDelegate.h"
#import "DarkSkyAPI.h"
//#import "Credentials.h"

I had imported Credentials.h already in the DarkSkyAPI.m file in my project. Commenting out the extra import made the error go away!

我已经在我的项目的 DarkSkyAPI.m 文件中导入了 Credentials.h。注释掉额外的导入会使错误消失!

Some things to mention and maybe help anyone in the future. @umairqureshi_6's answer did help me along the process, but did not solve it. He led to where I was able to dig out the info. I kept seeing AppDelegate and DarkSkyAPI files showing up in the error log and the information it was pulling from Credentials file was causing the error. I knew it had to be in one of these 3 files, so I immediately checked imports, because I remembered hearing that the .h carries all the imports from its .m file. Boom!

有些事情要提,也许将来可以帮助任何人。@umairqureshi_6 的回答确实在整个过程中帮助了我,但没有解决。他把我带到了可以挖掘信息的地方。我一直在错误日志中看到 AppDelegate 和 DarkSkyAPI 文件,并且它从 Credentials 文件中提取的信息导致了错误。我知道它必须在这 3 个文件之一中,所以我立即检查了导入,因为我记得听说 .h 包含来自其 .m 文件的所有导入。繁荣!

回答by Priyanka

I k now the question has already been answered. But if this helps somebody save some time : I had the same error. I checked everything to find a very small and stupid mistake from my side. I imported a core data ManagedObject custom file in a view controller of my project. I accidentally imported the .m file instead of the .hfile which was causing the duplicate symbol in architecture error (linker command failed) because my .m file of properties class imports the .h file of core data class and hence causing duplicate import.

我知道这个问题已经得到了回答。但是,如果这有助于某人节省一些时间:我有同样的错误。我检查了所有内容,以发现我身边的一个非常小而愚蠢的错误。我在项目的视图控制器中导入了一个核心数据 ManagedObject 自定义文件。我不小心导入了 .m 文件而不是 .h文件,这导致架构错误中的重复符号(链接器命令失败),因为我的属性类的 .m 文件导入了核心数据类的 .h 文件,因此导致重复导入。

So just check if u have imported the right files before you try multiple solutions.!

因此,在尝试多种解决方案之前,请检查您是否导入了正确的文件。!

回答by Aaban Tariq Murtaza

A lot of solutions are mentioned above. No one worked for me(but please try above first).

上面提到了很多解决方案。没有人为我工作(但请先尝试以上)。

Select Project -> Select Target -> Linked Framework and Libraries -> Add all pod libraries . (remove if they exist in embedded binaries)

选择 Project -> Select Target -> Linked Framework and Libraries -> Add all pod libraries 。(如果它们存在于嵌入式二进制文件中,则删除)

Now remove these from Framework Folder in left file explorer of xcode.

现在从 xcode 左侧文件资源管理器中的框架文件夹中删除这些。

This solved my issue.

这解决了我的问题。

回答by K Prasad

Select the project-> Build Phase->Link Binary with libraries and add all pod libraries.

选择项目-> Build Phase->Link Binary with libraries 并添加所有 pod 库。

回答by Adri Silva

I had the same problem using Carthage for dependencies.

我在使用 Carthage 依赖项时遇到了同样的问题。

Just go to Select Project -> Build Settings -> Search for Enable Bitcode -> If it is selected to Yes, select No.

只需转到 Select Project -> Build Settings -> Search for Enable Bitcode -> 如果选择 Yes,选择 No。

That solved this problem for me.

那为我解决了这个问题。

回答by Ajit A. Kenjale

I had same problem.

我有同样的问题。

The cause was that I declared same global variable in 2 files. So it was showing same error saying 2 duplicate symbols.

原因是我在 2 个文件中声明了相同的全局变量。所以它显示了同样的错误,说2 个重复的符号

The solution was to remove those variables.

解决方案是删除这些变量。