objective-c Xcode 中的链接错误

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

Linking Error in Xcode

objective-cxcodelinker

提问by Biranchi

I am getting this error after adding the libxml2.2.dylib file

添加 libxml2.2.dylib 文件后出现此错误

 Linking /Users/Biranchi/Desktop/Funmovies TabBarController/build/Debug-iphonesimulator/funmovies.app/funmovies (1 error)
 in /Developer/Platforms/iphoneOS.platform/Developer/SDKs/iphoneOS3.0.sdk/lib/libobjc.A.dylib, missing required architecture i386 in file

Command /XCode3.1.4/platforms/iphoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

What is this error due to ??

这个错误是什么原因造成的??

All suggestions are appreciated.

所有建议表示赞赏。

Thanks Biranchi

谢谢比兰奇

采纳答案by Oleksii

Got the same error, now even when I`ve deleted libxml2 from project error still here :) This sh**y XCode wrote this:

得到了同样的错误,现在即使我从项目中删除了 libxml2 错误仍然在这里:) 这个 sh**y XCode 写了这个:

LIBRARY_SEARCH_PATHS = (
+                    "$(inherited)",
+                    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib,
+                );

into project`s config file "project.pbxproj" in "MyProj.xcodeproj".

进入“MyProj.xcodeproj”中的项目配置文件“project.pbxproj”。

You can change this path by hands to something like:

您可以手动将此路径更改为:

LIBRARY_SEARCH_PATHS = (
+                    "$(inherited)",
+                    /Developer/Platforms/iPhoneSimulatorOS.platform/Developer/SDKs/iPhoneSimulatorOS3.0.sdk/usr/lib,
+                );

But do not forget to change it back when compile into device. I`ll try to find more simple way to resolve this problem.

但是不要忘记在编译到设备时将其改回来。我会尝试找到更简单的方法来解决这个问题。

回答by hfossli

Make sure you import with correct extension.

确保使用正确的扩展名导入。

I got the error when I by mistake wrote #import "AClass.m"instead of #import "AClass.h":-)

当我错误地写#import "AClass.m"而不是#import "AClass.h":-)时,我得到了错误

回答by mracoker

I had to remove this library libz.1.2.3.dylib and add this one libz.1.2.5.dylib. After that it compiled fine.

我不得不删除这个库 libz.1.2.3.dylib 并添加这个 libz.1.2.5.dylib。之后它编译得很好。

回答by Brooks Hanes

Try Product -> Clean. Worked for me.

尝试产品 -> 清洁。对我来说有效。

回答by JH95

How to add as a compiled source

如何添加为编译源

Make sure if you have external classes they are added in the compile sources. I had the same error when i was trying to import a certain class. To fix it goto build phases and add it into the compiled sources.

确保您有外部类,它们被添加到编译源中。当我尝试导入某个类时,我遇到了同样的错误。要修复它,请转到构建阶段并将其添加到已编译的源代码中。

回答by Cordeiro

I had a similar problem when building a project but this time with the file timbreID.c

我在构建项目时遇到了类似的问题,但这次使用文件 timbreID.c

arm-apple-darwin10-gcc-4.2.1: timbreID.c: No such file or directory
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

After several attempts I finally looked into the 'Targets' on my XCode project and realized that the file timbreID.c was red (= not found). I right-clic on it and chose the new path manually.

经过多次尝试,我终于查看了 XCode 项目中的“目标”,并意识到文件 timbreID.c 是红色的(= 未找到)。我右键单击它并手动选择新路径。

After that: build succeeded!!

之后:构建成功!!

回答by AppleIosPandi

just remove the libz1.2.3 and add the libz1.2.5 library to your build phase.

只需删除 libz1.2.3 并将 libz1.2.5 库添加到您的构建阶段。

回答by Graham P Heath

If this is a problem related to a specific frame work, make sure it is enabled in the build phase. For me I had to add MessageUI.framework: In Xcode 4 goto the build phases tab for your target. Make sure you see the frameworks you are using. If it's not there click + to add it.

如果这是与特定框架相关的问题,请确保在构建阶段启用它。对我来说,我必须添加 MessageUI.framework:在 Xcode 4 中,转到目标的构建阶段选项卡。确保您看到正在使用的框架。如果它不存在,请单击 + 以添加它。

回答by Sukitha Udugamasooriya

I had the same problem and I went on checking the target info

我遇到了同样的问题,我继续检查目标信息

In the library search paths there was this entry, "$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/lib"

在库搜索路径中有这个条目,“$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/lib”

I removed it and the app WORKED!!!

我删除了它,应用程序工作了!!!

回答by 18446744073709551615

Try to issue the failed command from the command line. There, you will see the stderr output that is not shown via GUI.

尝试从命令行发出失败的命令。在那里,您将看到未通过 GUI 显示的 stderr 输出。