xcode iOS - 文件是为存档构建的,而不是被链接的架构 (i386)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7873004/
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
iOS - file was built for archive which is not the architecture being linked (i386)
提问by KaiserJohaan
I got a few static libraries I want to use in my iphone app. When I try to run the simulator I get linking errrors. I am new to iOS development, and I ran into this problem when linking against libraries I built previously;
我想在我的 iphone 应用程序中使用一些静态库。当我尝试运行模拟器时,出现链接错误。我是 iOS 开发的新手,在链接我之前构建的库时遇到了这个问题;
file was built for archive which is not the architecture being linked (i386)
Which means all the functions I reference from those libraries gives me this:
这意味着我从这些库中引用的所有函数都给了我这个:
undefined symbols for architectyre i386
I am not sure what to configure to make this right. The static libraries are build for armv7, supporteed platforms armv6 armv7.
我不确定要配置什么才能做到这一点。静态库是为 armv7 构建的,支持的平台 armv6 armv7。
回答by Ed Gonzalez
I sorted a very similar error with a static library I was building for iPad. I believe my solution was to add "i386" to the Architectures setting for the project (Click on the Project -> Build Settings -> Architectures --or was it Valid Architectures?-- and click the '+' icon, type "i386" in the highlighted line). Anywho that should get you close.
我使用为 iPad 构建的静态库对一个非常相似的错误进行了排序。我相信我的解决方案是将“i386”添加到项目的体系结构设置中(单击项目 -> 构建设置 -> 体系结构 -- 或者它是有效的体系结构?-- 然后单击“+”图标,键入“i386” " 在突出显示的行中)。任何应该让你接近的人。
Oh, one more caveat, I've read that we should set "Build Active Architecture Only" to "No" as well. It was already set for me, but that's something you might want to check.
哦,还有一个警告,我读过我们应该将“仅构建活动架构”设置为“否”。它已经为我设置了,但这是您可能想要检查的内容。
回答by Cody A. Ray
After struggling with this same problem and following all the accepted answers of updating build settings, clearing the linker search path, etc.. I finally discovered an answer that worked for me.
在解决了同样的问题并遵循更新构建设置、清除链接器搜索路径等所有公认的答案之后……我终于找到了一个对我有用的答案。
Before building, make sure you select right type (iPhone Simulator) instead of iOS Device. Then rebuild. Otherwise, you're trying to use a library built for an iOS device (arm processor) on a simulator (i386). Should've been obvious, but wasn't.
在构建之前,请确保选择正确的类型(iPhone 模拟器)而不是 iOS 设备。然后重建。否则,您将尝试在模拟器 (i386) 上使用为 iOS 设备(arm 处理器)构建的库。应该很明显,但不是。
Before:
前:
After:
后:
Now, look in the Products group in the Navigator > right click your static library (.a file) > Show in Finder, you'll notice that its in a Debug-iphonesimulator folder instead of Debug-iphoneos. I didn't pay any attention to the folder name originally, or I might have thought of this sooner.
现在,查看导航器中的产品组> 右键单击您的静态库(.a 文件)> 在 Finder 中显示,您会注意到它位于 Debug-iphonesimulator 文件夹中,而不是 Debug-iphoneos。原来我没注意文件夹名,要不我早想到了。
Hope this helps.
希望这可以帮助。