简体   繁体   English

Apple Mach-O链接器错误-ld:找不到文件:-ObjC

[英]Apple Mach-O Linker Error - ld: file not found: -ObjC

I've inherited an iOS project and can't even get it to build. 我继承了一个iOS项目,甚至无法构建它。 I keep getting the following error: 我不断收到以下错误:

ld: file not found: -ObjC
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've seen posts about the 'file not found' error but none pertaining to the '-ObjC' bit that looks like a switch. 我看到过有关“找不到文件”错误的信息,但都与看起来像开关的“ -ObjC”位无关。

Any ideas? 有任何想法吗?

-ObjC is a valid option to ld , however it's possible to confuse ld if some other option is broken. -ObjCld的有效选项,但是如果某些其他选项被破坏,则有可能使ld混淆。 For example the -framework option requires an argument and if that argument (the name of the framework) is missing then that would cause the sort of error you are seeing. 例如, -framework选项需要一个参数,如果缺少该参数(框架的名称),则将导致您看到的那种错误。

ld ... -framework -ObjC

However I cannot tell you exactly where the error is without seeing the complete linker command line. 但是,如果看不到完整的链接器命令行,就无法确切告诉您错误的出在哪里。

Look through your build settings, both in Xcode and in xcconfig file. 浏览Xcode和xcconfig文件中的构建设置。

I have seen people adding an option - ObjC to some build settings for no good reason at all, and the linker may interpret that as a request to link a file named ObjC or -ObjC. 我见过人们毫无理由地在某些构建设置中添加了一个选项-ObjC,链接器可能会将其解释为链接名为ObjC或-ObjC的文件的请求。

Thanks everyone, I managed to sort it. 谢谢大家,我设法进行了排序。

@Droppy pointed me in the right direction. @Droppy向我指出了正确的方向。

Before the -ObjC flag there was another called -force_all . 在之前-ObjC标志还有一个叫-force_all I then stumbled across this answer which indicated that you only need the -ObjC flag. 然后,我偶然发现了这个答案该答案表明您只需要-ObjC标志。 I removed -force_all and it started to work! 我删除了-force_all ,它开始起作用!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM