ios 链接器命令失败,Xcode 项目中出现退出代码 1 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10811001/
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 error in Xcode project
提问by user1374408
I was working on my project and suddenly after editing the code and compiling gave this error:
我正在处理我的项目,在编辑代码和编译后突然出现了这个错误:
ld: warning: directory not found for option '-
L/Users/mani/Documents/Classes/Twitter+OAuth/Libraries & Headers' ld: duplicate symbol _OBJC_CLASS_$_playSiew in /Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/playSiew.o and /Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/Thumb.o for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld:警告:找不到选项“-
L/Users/mani/Documents/Classes/Twitter+OAuth/Libraries & Headers”的目录 ld:/Users/mani/Library/Developer/Xcode/DerivedData/ 中的重复符号 _OBJC_CLASS_$_playSiew learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/playSiew.o 和/Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates /learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/Thumb.o 对于架构 i386 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
I never touched the project settings, just edited the code.
我从未接触过项目设置,只是编辑了代码。
What's more strange is that I took out last revised code from svn but still I got the the same error.
更奇怪的是,我从 svn 中取出了最后修改过的代码,但仍然出现相同的错误。
采纳答案by user1374408
As I said the problem wasn't the code but some settings. So what I did was copying the code from my friends' Mac (it was working fine), and installed a fresh copy of the project to my Mac. It worked.
正如我所说,问题不在于代码,而在于一些设置。所以我所做的是从我朋友的 Mac 复制代码(它工作正常),并将该项目的一个新副本安装到我的 Mac 上。有效。
回答by CodaFi
You may be accidentally #import
'ing a .m file instead of a .h. Use Cmd+Shift+F and search for ".m" (without quotes). It will most likely lie in one of the classes mentioned in the warning. If not, clean and run again.
您可能不小心使用#import
了 .m 文件而不是 .h。使用 Cmd+Shift+F 并搜索“.m”(不带引号)。它很可能位于警告中提到的类之一。如果没有,请清洁并再次运行。
回答by Narendra Ojha
I was also having same issue and I did following and issue is gone.
我也遇到了同样的问题,我做了以下操作,问题消失了。
Go to Product-> Cleanand re-run the project.
转到Product-> Clean并重新运行该项目。
I hope it might be useful for some other developers.
我希望它可能对其他一些开发人员有用。
回答by Dan
After running into this problem a few minutes ago (yes, I know it's been 7 months since the original thread) I found that the root of my issue was due to me dragging & dropping files into my project within XCode instead of right-clicking and choosing Add Files to Project.
几分钟前遇到这个问题后(是的,我知道距原始线程已经过去 7 个月了)我发现问题的根源是由于我在 XCode 中将文件拖放到我的项目中而不是右键单击并选择将文件添加到项目。
回答by Dashzaki
Check playSiew.m is in Compile Sources section. isn't it?
检查 playSiew.m 在编译源部分。不是吗?
You can find Compile Sources section follow this step
您可以按照此步骤找到编译源部分
- Select YourProjectName
- Select TARGETS
- Select Build Phases
- 选择您的项目名称
- 选择目标
- 选择构建阶段
If don't have playSiew.m in this section . You must to add it to this section.
如果本节中没有 playSiew.m 。您必须将其添加到此部分。
回答by BrianHenryIE
I was importing a libraryin a test case which I had specified in my pod filefor the main target but not for the test target.
我在一个测试用例中导入了一个库,我在我的pod 文件中为主要目标指定了一个库,但没有为测试目标指定。
回答by Thyselius
If you're working in Unity and export to iOS and you are using a plugin, go to Xcode Build Settings and set ENABLE BITCODE = NO. I'm guessing this might apply to other situations as well
如果您在 Unity 中工作并导出到 iOS 并且您正在使用插件,请转到 Xcode Build Settings 并设置 ENABLE BITCODE = NO。我猜这也可能适用于其他情况
回答by ScottyB
I also got this error because I had accidentally included two versions of the same source file. Deleted the wrong one and the problem went away...
我也遇到了这个错误,因为我不小心包含了同一个源文件的两个版本。删错了,问题就解决了……
回答by shri
Faced similar issue, while running the code on a simulator, tried all the above mentioned options, still got the same error. Tried connecting the iOS device and build the code, it worked for us. This can be a quick workaround.
遇到类似的问题,在模拟器上运行代码时,尝试了上述所有选项,仍然出现相同的错误。尝试连接 iOS 设备并构建代码,它对我们有用。这可能是一个快速的解决方法。
回答by Christina
In case this comes in useful for anyone else--I just had this same error, and turns out the cause was initializing a variable in my header file rather than in the main file.
如果这对其他人有用——我只是遇到了同样的错误,结果证明原因是在我的头文件而不是主文件中初始化了一个变量。