xcode 找不到架构 i386 的 iOS 符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13230040/
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 symbols not found for architecture i386
提问by Ashutosh Bhatt
I have made a static library after going through http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/. To test this library i made a new project and drag the static library on to the project and tried to test its one method. But it is giving me the error " "_OBJC_CLASS_$_MyLib", referenced from:". MyLib is the name of the library i created.
通过http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/后,我制作了一个静态库。为了测试这个库,我创建了一个新项目并将静态库拖到项目上并尝试测试它的一种方法。但它给了我错误““_OBJC_CLASS_$_MyLib”,引用自:”。MyLib 是我创建的库的名称。
Steps i took in creating static library. 1. Created a new Xcode project. 2. Choose option to create cocoa touch static library. 3. Wrote two functions in MyLib.h and wrote the implementations one for fibonacci series and other for generating factorial of a number. 3. Built the project and write click on the MyLib.a file with the portion to reveal in finder. 4. Drag MyLib.a file and MyLib.h in a new folder called MyLib.
我在创建静态库时采取的步骤。1. 创建了一个新的 Xcode 项目。2. 选择创建可可触摸静态库的选项。3. 在 MyLib.h 中编写了两个函数,并编写了一个用于斐波那契数列的实现,另一个用于生成数字的阶乘。3. 建好工程,点击MyLib.a文件,在finder中显示部分。4. 将 MyLib.a 文件和 MyLib.h 拖到名为 MyLib 的新文件夹中。
Any help please
请任何帮助
回答by deleted_user
When building libraries, frameworks or applications for iOS, XCode will only compile object code for the architectures specified in the build settings for the target. XCode will also only link to binaries that have the specified architecture built in.
在为 iOS 构建库、框架或应用程序时,XCode 只会为目标的构建设置中指定的架构编译目标代码。XCode 也将只链接到具有内置指定架构的二进制文件。
In XCode if you select your target you can see under the build settings tab, the architecture for your target. It will contain values like arm6, arm7, and i386.
在 XCode 中,如果您选择目标,您可以在构建设置选项卡下看到目标的架构。它将包含 arm6、arm7 和 i386 等值。
When running code in the iOS simulator you are running your code on your desktop which is the i386 architecture.
在 iOS 模拟器中运行代码时,您是在 i386 架构的桌面上运行代码。
When running on the device the binary has "slices" which are built for that architecture. If the correct architecture "slice" is not present in the binary, it will not run.
在设备上运行时,二进制文件具有为该架构构建的“切片”。如果二进制文件中不存在正确的架构“切片”,它将不会运行。
If you get the missing i386 architecture error running an iOS application in the simluator you need to make sure that your application and all its dependent libraries have been built for i386 architecture.
如果您在模拟器中运行 iOS 应用程序时遇到缺少 i386 架构的错误,您需要确保您的应用程序及其所有依赖库都是为 i386 架构构建的。
Also check that "build active architecture only" is set to NO in the build settings for the target.
还要检查目标的构建设置中的“仅构建活动架构”是否设置为 NO。
If you cant rebuild dependent libraries because you dont have the source, you will have to test on a device supporting arm6 or arm7 architecture.
如果因为没有源码而无法重建依赖库,则必须在支持 arm6 或 arm7 架构的设备上进行测试。
回答by Siddhartha Saif
I had same Problem when i tried to add a c header in cpp file like below
当我尝试在 cpp 文件中添加 ac 头时遇到了同样的问题,如下所示
//in c++ header file
#import "cHeader.h"
After a long struggling period I learnt that to import c header in cpp file you need to do this:
经过长时间的挣扎,我了解到要在 cpp 文件中导入 c 头文件,您需要执行以下操作:
//in c++ header file
extern "C"{
#import "cHeader.h"
}
and my problem was solved.
我的问题解决了。
回答by Aaron
I had the exact same problem and was finally able to get it working in Xcode 4.5 and iOS 6 when I read the answer on this thread. The answer by @idz works well but its not ideal that you have to include the library's project in your app's project and then set it as a dependency.
我遇到了完全相同的问题,当我阅读此线程上的答案时,我终于能够在 Xcode 4.5 和 iOS 6 中运行它。@idz 的答案很有效,但您必须将库的项目包含在应用程序的项目中,然后将其设置为依赖项,这并不理想。
Steps 1-8 are very simple and explicit. You also need to ensure that the header search paths project setting is accurate. Good luck!
步骤 1-8 非常简单和明确。您还需要确保标题搜索路径项目设置准确。祝你好运!