简体   繁体   English

链接器命令失败,Xcode项目中出现退出代码1错误

[英]Linker command failed with exit code 1 error in Xcode project

I was working on my project and suddenly after editing the code and compiling gave this error: 我正在处理我的项目,并在编辑代码后突然编译并发出此错误:

ld: warning: directory not found for option '- ld:警告:找不到选项的目录' -
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) L / Users / mani / Documents / Classes / Twitter + OAuth / Libraries&Headers'ld:重复符号_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和/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中取出了最后修改过的代码但仍然得到了同样的错误。

You may be accidentally #import 'ing a .m file instead of a .h. 您可能会意外地#import输入.m文件而不是.h。 Use Cmd+Shift+F and search for ".m" (without quotes). 使用Cmd + Shift + F并搜索“.m”(不带引号)。 It will most likely lie in one of the classes mentioned in the warning. 它很可能位于警告中提到的一个类中。 If not, clean and run again. 如果没有,请清洁并再次运行。

I was also having same issue and I did following and issue is gone. 我也有同样的问题,我做了跟随,问题消失了。

Go to Product -> Clean and re-run the project. 转到产品 - > 清理并重新运行项目。

I hope it might be useful for some other developers. 我希望它可能对其他一些开发人员有用。

几分钟前遇到这个问题(是的,我知道自原始主题开始已有7个月)我发现问题的根源是由于我在XCode中将文件拖放到我的项目中而不是右键单击选择添加文件到项目。

Check playSiew.m is in Compile Sources section. 检查playSiew.m是否在Compile Sources部分。 isn't it? 不是吗?

You can find Compile Sources section follow this step 您可以在此步骤中找到“编译源”部分

  1. Select YourProjectName 选择YourProjectName
  2. Select TARGETS 选择TARGETS
  3. Select Build Phases 选择Build Phases

If don't have playSiew.m in this section . 如果在本节中没有playSiew.m。 You must to add it to this section. 您必须将其添加到此部分。

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. 所以我所做的就是从朋友的Mac上复制代码(它运行正常),并将新项目的副本安装到我的Mac上。 It worked. 有效。

我在一个测试用例中导入了一个 ,我在我的pod文件中指定了主要目标但不是测试目标

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... 删除了错误的一个,问题就消失了......

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. 如果您在Unity中工作并导出到iOS并且您正在使用插件,请转到Xcode Build Settings并设置ENABLE BITCODE = NO。 I'm guessing this might apply to other situations as well 我猜这也可能适用于其他情况

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. 尝试连接iOS设备并构建代码,它对我们有用。 This can be a quick workaround. 这可以是一个快速的解决方法。

the same error i faced. 我面临同样的错误。 so, i just removed reference of that classes which are generating the errors and than again gave reference and the error was gone... 所以,我刚刚删除了那些产生错误的类的引用,并再次提供了参考,错误消失了......

as D80Buckeye says there should be problem of dragging and dropping files instead of Clicking on "Add Files" 正如D80Buckeye所说,应该存在拖放文件的问题,而不是单击“添加文件”

如果这对其他任何人都有用 - 我只是遇到了同样的错误,原因是在我的头文件中而不是在主文件中初始化变量。

I just encountered the same error. 我刚遇到同样的错误。 If you are using embedded Libraries, make sure your Deployment Target is set to iOS 8.0 or higher. 如果您使用的是嵌入式库,请确保将部署目标设置为iOS 8.0或更高版本。

你只需要添加以下框架:quartzcore.framework

The only way we can get past this bug on our project is to do a Clean and then build for iPad Retina. 我们可以通过我们的项目来解决这个问题的唯一方法就是为iPad Retina做一个Clean然后构建。 After that it will build successfully for any device. 之后,它将成功构建任何设备。 Weird. 奇怪的。

In my case i have add reference of FacebookLoginSDK framework but forget to give search path in build setting. 在我的情况下,我添加了FacebookLoginSDK框架的参考,但忘记在构建设置中提供搜索路径。 After removing its reference everything was fine. 删除它的参考后一切都很好。

So conclusion is if you are adding any external framework be careful. 所以结论是,如果你要添加任何外部框架要小心。

If this happens to you with CoreData generated classes, combine the +CoreDataProperties and +CoreDataClass into the +CoreDataProperties class and delete the +CoreDataClass. 如果您使用CoreData生成的类,则将+ CoreDataProperties和+ CoreDataClass组合到+ CoreDataProperties类中并删除+ CoreDataClass。 Make sure to search Derived Data for leftovers of the +CoreDataClass. 确保在Derived Data中搜索+ CoreDataClass的剩余部分。 Even after deleting the Derived Data and cleaning I sometimes had Xcode just generate the +CoreDataClass again and again. 即使在删除派生数据和清理后,我有时也会让Xcode一次又一次地生成+ CoreDataClass。 Deleting it manually in Finder and then re-bulding helped me solve this. 在Finder中手动删除它然后重新建立帮助我解决了这个问题。

try this, go to Target -> Build Settings,then search these three as following, 试试这个,转到Target - > Build Settings,然后按以下方式搜索这三个,

GCC_NO_COMMON_BLOCKS, GCC_NO_COMMON_BLOCKS,

CLANG_WARN_INFINITE_RECURSION, CLANG_WARN_INFINITE_RECURSION,

CLANG_WARN_SUSPICIOUS_MOVE, CLANG_WARN_SUSPICIOUS_MOVE,

set NO to each value then clean and build. 为每个值设置NO然后清理并构建。

I tried several of the answers listed but none worked for me. 我尝试了几个列出的答案,但没有一个适合我。 I got the error after updating XCode (while it was still open which may have contributed to the problem) 更新XCode后我得到了错误(当它仍然打开时可能导致问题)

First , I deleted my Derived Data folder: XCode => Preferences => Locations => Double Click on arrow next to path indicating where the Derived Data folder is. 首先 ,我删除了Derived Data文件夹:XCode => Preferences => Locations => Double单击路径旁边的箭头,指示Derived Data文件夹的位置。 Then "Move to Trash" I don't think that's what the problem was, but it's amazing how many times this has been an issue for me working on different problems. 然后“移动到垃圾箱”我不认为这就是问题所在,但令人惊讶的是,这对于我解决不同问题是多少次问题。

Second , I 'Quit' the simulator. 其次 ,我'退出'模拟器。

Third , I 'Quit' XCode. 第三 ,我'退出'XCode。

Fourth , I opened up my project in XCode again and then did a Clean and Build (found in the Product menu) 第四 ,我再次在XCode中打开了我的项目,然后做了一个Clean and Build(在产品菜单中找到)

Fifth , I ran my project and it worked fine 第五 ,我运行我的项目,它工作正常

Cleaning the project not works for me. 清洁项目不适合我。 Restart the Xcode works for me... 重启Xcode对我有用......

For me it was different. 对我而言,情况有所不同。 I had the same error when I removed a Pod and solved it by removing this pod from the Other Linker Flags in the Build Settings 当我删除Pod并通过从Build Settings中Other Linker Flags中删除此pod来解决它时,我遇到了同样的错误

在此输入图像描述

then clean your project [Product > Clean] and rebuild 然后清理您的项目[产品>清洁]并重建

Go to general and linked frameworks and libraries in xcode and remove all the files there. 转到xcode中的常规和链接框架和库,并删除那里的所有文件。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 铛:错误:链接器命令失败,退出代码为1 - clang: error: linker command failed with exit code 1 错误 - linker 命令失败,退出代码为 1 - Error - linker command failed with exit code 1 xcode7:命中链接程序命令失败,退出代码为1 - xcode7: hit linker command failed with exit code 1 under Xcode链接器命令失败,退出代码为1(使用-v查看调用) - Xcode linker command failed with exit code 1 (use -v to see invocation) XCode 7:链接器命令失败,退出代码为1(使用-v查看调用) - XCode 7 : linker command failed with exit code 1 (use -v to see invocation) Xcode 5 - clang:错误:链接器命令失败,退出代码为1(使用-v查看调用) - Xcode 5 - clang: error: linker command failed with exit code 1 (use -v to see invocation) 如何解决错误:链接器命令失败,退出代码1(在-Xcode5中使用-v查看调用) - How to resolve error: linker command failed with exit code 1 (use -v to see invocation) in Xcode5 链接器命令失败,退出代码为1 - linker command failed with exit code 1 iPhone链接器错误:命令/ usr / sbin / chown失败,退出代码为1 - iPhone Linker error : Command /usr/sbin/chown failed with exit code 1 错误:链接器命令失败,退出代码为1(使用-v查看调用) - error: linker command failed with exit code 1 (use -v to see invocation)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM