ios 找不到架构 i386 的符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4839981/
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
symbol(s) not found for architecture i386
提问by Doz
When trying to compile with Xcode, I am getting the following error:
尝试使用 Xcode 进行编译时,出现以下错误:
**Ld /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator/iKosher.app/iKosher normal i386
cd /Users/doronkatz/Sites/xCode/iKosher
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Xcode4/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Xcode4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Xcode4/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -L/Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator -L/Users/doronkatz/Sites/xCode/iKosher -F/Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator -filelist /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Intermediates/iKosher.build/Debug-iphonesimulator/iKosher.build/Objects-normal/i386/iKosher.LinkFileList -mmacosx-version-min=10.6 -all_load -ObjC -Xlinker -objc_abi_version -Xlinker 2 -lz -framework Security -framework CFNetwork -framework CoreData -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -o /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator/iKosher.app/iKosher
Undefined symbols for architecture i386:
"_UTTypeCreatePreferredIdentifierForTag", referenced from:
+[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
"_UTTypeCopyPreferredTagWithClass", referenced from:
+[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
"_kUTTagClassMIMEType", referenced from:
+[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
"_kUTTagClassFilenameExtension", referenced from:
+[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
"_SCNetworkReachabilitySetCallback", referenced from:
-[Reachability startNotifier] in Reachability.o
"_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
-[Reachability startNotifier] in Reachability.o
"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
-[Reachability stopNotifier] in Reachability.o
"_SCNetworkReachabilityCreateWithName", referenced from:
+[Reachability reachabilityWithHostName:] in Reachability.o
"_SCNetworkReachabilityCreateWithAddress", referenced from:
+[Reachability reachabilityWithAddress:] in Reachability.o
"_SCNetworkReachabilityGetFlags", referenced from:
-[Reachability currentReachabilityStatus] in Reachability.o
-[Reachability isReachable] in Reachability.o
-[Reachability isConnectionRequired] in Reachability.o
-[Reachability isConnectionOnDemand] in Reachability.o
-[Reachability isInterventionRequired] in Reachability.o
-[Reachability isReachableViaWWAN] in Reachability.o
-[Reachability isReachableViaWiFi] in Reachability.o
...
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status**
Not sure what it means.
不知道是什么意思。
采纳答案by epatel
You are using ASIHTTPRequest so you need to setup your project. Read the second part here
您正在使用 ASIHTTPRequest,因此您需要设置您的项目。在这里阅读第二部分
回答by Doz
If you get this sort of thing appearing suddenly, it usually means the project is missing some frameworks it needs. Libraries and dependent projects can require frameworks, so if you've added one recently then that can cause this error.
如果你突然出现这种事情,通常意味着项目缺少一些它需要的框架。库和相关项目可能需要框架,因此如果您最近添加了框架,则可能会导致此错误。
To add frameworks, right click on the project name in the project view, select Add
, then select Existing frameworks...
from the list. Then find the framework with the symbols you're missing.
要添加框架,请在项目视图中右键单击项目名称,选择Add
,然后Existing frameworks...
从列表中进行选择。然后找到带有您缺少的符号的框架。
As to how you find which frameworks you need, I've found using google the easiest, though you could probably use the Xcode help search too. Search for one of the symbols, doing your best to work out the unmangled name (e.g., SCNetworkReachabilityGetFlags
), and then the first documentation link you find at developer.apple.com is often the right one. You usually don't have to hunt very far. In this case, that's this page:
至于如何找到您需要的框架,我发现使用 google 是最简单的,尽管您也可以使用 Xcode 帮助搜索。搜索其中一个符号,尽力找出未混淆的名称(例如,SCNetworkReachabilityGetFlags
),然后您在 developer.apple.com 上找到的第一个文档链接通常是正确的。你通常不必打猎很远。在这种情况下,就是这个页面:
https://developer.apple.com/documentation/systemconfiguration/scnetworkreachability-g7d
https://developer.apple.com/documentation/systemconfiguration/scnetworkreachability-g7d
Then at the top of the page, it tells you which framework to use, SystemConfiguration
in this case. So add that to the project, and compile again.
然后在页面顶部,它会告诉您SystemConfiguration
在这种情况下使用哪个框架。因此,将其添加到项目中,然后再次编译。
Then just keep doing this until it works...
然后继续这样做直到它起作用为止......
Edit: I've never used the simulator, but this is what you do on the device - I assume it's the same...
编辑:我从未使用过模拟器,但这就是你在设备上所做的 - 我认为它是一样的......
回答by Nir Pengas
Sometimes there are source files which are missing from your target.
有时目标中缺少源文件。
- examine which symbols are missing
- target->build phases->compile source
- add the missing source files if they are not listed
- command+b for bliss
- 检查缺少哪些符号
- 目标->构建阶段->编译源
- 如果未列出,请添加缺少的源文件
- 命令+b 幸福
You can select the files that seem to be "missing" and check in the right-hand utility bar that their checkboxes are selected for the Target you are building.
您可以选择似乎“丢失”的文件,并在右侧的实用程序栏中检查是否为您正在构建的目标选中了它们的复选框。
回答by Pruthvid
I solved it using the following method (for XCode 4):
我使用以下方法解决了它(对于 XCode 4):
1) Select the project in the project navigation window which will show project summary on right
1) 在项目导航窗口中选择项目,右侧会显示项目摘要
2) Select 4th tab build phases
2) 选择第 4 个选项卡构建阶段
3) Select Link binary with library option
3) 选择 Link binary with library 选项
4) Add framework for which you are getting
4)添加您正在获得的框架
5) Move the framework from main folder to the frameworks folder
5)将框架从主文件夹移动到框架文件夹
6) Build it again and errors are gone.
6)再次构建它,错误消失了。
回答by justinkoh
Thought to add my solution for this, after spending a few hours on the same error :(
在花了几个小时处理相同的错误后,我想为此添加我的解决方案:(
The guys above were correct that the first thing you should check is whether you had missed adding any frameworks, see the steps provided by Pruthvid above.
上面的人是正确的,您应该检查的第一件事是您是否错过了添加任何框架,请参阅上面 Pruthvid 提供的步骤。
My problem, it turned out, was a compile class missing after I deleted it, and later added it back in again.
事实证明,我的问题是在我删除它之后缺少一个编译类,后来又重新添加了它。
Check your "Compile Sources" as shown for the reported error classes. Add in any missing classes that you created.
检查您的“编译源”,如报告的错误类所示。添加您创建的任何缺失的类。
回答by Lithu T.V
The problem is that target membership for the added filed is missing to the app target .So select the file and add the checkmark to the box of target membership
问题是应用程序目标缺少添加的文件的目标成员资格。因此选择文件并将复选标记添加到目标成员资格框
For example if the error shown in a method definition in common.m
例如,如果在 common.m 中的方法定义中显示错误
回答by Tibidabo
Make sure that the missing framework is actually listed under "Target/Build Phases/Link Binary With Libraries"if not just add it. As mentioned before it usually indicates a missing framework.
如果不只是添加它,请确保缺少的框架实际上列在“目标/构建阶段/链接二进制与库”下。如前所述,它通常表示缺少框架。
In my project there were two identical framework listed, when I removed one of them I had this error, because it also removed it form the the "Link Binary With Libraries" list. I added back and the problem disappeared (and I still have two frameworks listed)
在我的项目中列出了两个相同的框架,当我删除其中一个时出现此错误,因为它还从“链接二进制库”列表中删除了它。我加回来,问题消失了(我仍然列出了两个框架)
回答by Josh
I fixed a similar error on my project by changing the Build Settings > Architecturesfor ALLof my targets.
我通过改变固定在我的项目类似的错误生成设置>架构为所有的我的目标。
The problem:When I upgraded from Xcode 4.4 to Xcode 4.5, my project still compiled fine on the simulator but did not compile on devices. On devices it threw the error "symbol(s) not found for architecture armv7s,"along with the misleading "Apple Mach-O Linker Error" and "clang: error: linker command failed with exit code 1 (use -v to see invocation)."
问题:当我从 Xcode 4.4 升级到 Xcode 4.5 时,我的项目仍然在模拟器上编译得很好,但没有在设备上编译。在设备上,它抛出错误“找不到架构 armv7s 的符号”,以及误导性的“Apple Mach-O 链接器错误”和“clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)”
The cause (in my case):My project had multiple targets, and even though the Build Settings > Architectures for the main targetwas set to include armv7s architecture, the main target depended on another target (listed under Build Phases > Dependencies), and I hadn't thought to reset the Build Settings > Architectures for that other target, and I had to change that to include armv7s. I suppose the simulator and device run on different architectures, and that's why the simulator was OK while the device wasn't.
原因(就我而言):我的项目有多个目标,即使主要目标的构建设置 > 体系结构设置为包括 armv7s 体系结构,主要目标也依赖于另一个目标(在构建阶段 > 依赖项下列出),并且我没想过要为其他目标重置构建设置 > 架构,我不得不将其更改为包含 armv7s。我想模拟器和设备在不同的架构上运行,这就是为什么模拟器可以,而设备不行。
回答by James J
Does your project depend on another project, and is that a target in that project set up to be a direct dependency of your main target? If this is the case and the dependency isn't set up, the dependent target may not be getting built for all configurations (i.e. the simulator)
您的项目是否依赖于另一个项目,并且该项目中的目标是否设置为您的主要目标的直接依赖项?如果是这种情况并且未设置依赖项,则可能不会为所有配置(即模拟器)构建依赖目标
Just a wild guess.
只是一个疯狂的猜测。
回答by invalidname
Another situation that can cause this problem is if your code calls into C++, or is called by C++ code. I had a problem with my own .c file's utility function showing up as "symbol not found" when called from Obj-C. The fix was to change the file type: in Xcode 4, use the extended info pane to set the file type to "Objective-C++ Source"; in Xcode 3, use "Get Info" to change file type to "source.cpp.objcpp".
可能导致此问题的另一种情况是,如果您的代码调用 C++,或者被 C++ 代码调用。当从 Obj-C 调用时,我自己的 .c 文件的实用程序函数显示为“找不到符号”时出现问题。修复方法是更改文件类型:在 Xcode 4 中,使用扩展信息窗格将文件类型设置为“Objective-C++ Source”;在 Xcode 3 中,使用“获取信息”将文件类型更改为“source.cpp.objcpp”。