Xcode 6 错误 - “缺少必需的架构 i386"为 iOS 模拟器构建时 [英] Xcode 6 Error - "Missing Required Architecture i386" When Building for iOS Simulator

查看:46
本文介绍了Xcode 6 错误 - “缺少必需的架构 i386"为 iOS 模拟器构建时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义的 Objective-C 框架.我想将它导入任何给定的 iOS 项目,并在 iOS 模拟器和实际设备上使用其提供的功能.为了导入框架,我使用应用程序目标中的构建阶段> 链接二进制文件 设置来链接它.然后,我可以使用以下语句将其导入到我的一个类中:

I have created a custom Objective-C framework. I would like to import it into any given iOS project and use its provided functionality on both the iOS Simulator and an actual device. To import the framework, I link it using the Build Phases > Link Binary With Libraries setting in the app's target. I'm then able to import it into one of my classes with this statement:

#import <CustomFramework/CustomFramework.h>

我可以很好地实例化框架的类,但是当我尝试在设备上运行我的项目时,我收到以下错误消息:

I can instantiate my framework's classes just fine, but when I try to run my project on a device, I get the following error message:

dyld: Library not loaded: @rpath/CustomFramework.framework/CustomFramework
Referenced from: /var/mobile/Applications/A61E882D-481A-4C0B-B4FD-69F5D24968BF/TestApp.app/TestApp
Reason: image not found

如果我尝试在模拟器上运行它,我会收到不同的错误消息:

And if I try to run it on the simulator, I get a different error message:

ld: warning: ignoring file /Users/user/Desktop/CustomFramework.framework/CustomFramework, missing required architecture i386 in file /Users/user/Desktop/CustomFramework.framework/CustomFramework (2 slices)
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_CustomFramework", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

当我从框架实例化一个类时会发生这种情况.如果我导入了框架但没有实际使用它,我的应用程序就会成功构建.每当我出于某种原因从框架实例化一个类时,它都会出错.

This occurs when I instantiate a class from the framework. If I import the framework but don't actually use it, my app builds successfully. It just errors whenever I instantiate a class from the framework for some reason.

为了在设备上构建应用程序,我遵循了这个 所以答案.我没有链接框架,而是在目标的构建阶段设置中添加了一个新的复制文件阶段,将目标设置为框架,然后添加了我的框架.

To get the app to build on a device, I followed this SO answer. Instead of linking the framework, I added a new Copy Files phase in the target's Build Phases setting, set the Destination to Framework, and added my framework.

效果很好;但是,我也想在 iOS 模拟器上测试我的应用程序.当我尝试在模拟器上运行我的应用程序时,我仍然收到缺少所需的架构 i386"错误.我已经尝试了我能找到的几乎所有相关 SO 主题中提出的解决方案,但没有任何帮助我解决此问题.

That works great; however, I'd like to test my app on the iOS Simulator as well. When I try to run my app on the simulator, I still get the "missing required architecture i386" error. I've tried the solutions proposed at just about every related SO topic I could find, and nothing has helped me resolve this issue.

请注意,我正在尝试在新的 Xcode 项目中使用我的自定义框架,因此所有应用程序/构建设置均未更改其默认设置.

Please note that I am trying to use my custom framework in a new Xcode project, so none of the app/build settings have been changed from their defaults.

如何修复此错误,以便我可以在 iOS 模拟器和项目中包含我的框架的设备上运行我的应用程序?任何见解将不胜感激!

How can I fix this error so that I can run my app on both the iOS Simulator and a device with my framework included in the project? Any insight would be greatly appreciated!

推荐答案

问题是该框架没有针对 iOS Simulator 的架构(i386)进行编译.Xcode 只为目标架构编译框架,所以如果我为 iOS 模拟器构建框架,它在设备上将无法运行,如果我为设备构建框架,它在 iOS 模拟器上将无法运行.

The issue was that the framework was not compiled for the iOS Simulator's architecture, which is i386. Xcode only compiles a framework for the target architecture, so if I built the framework for the iOS Simulator, it wouldn't work on a device, and if I built the framework for a device, it wouldn't work on the iOS Simulator.

我在本教程的帮助下从头开始创建了我的框架:http://www.raywenderlich.com/65964/create-a-framework-for-ios

I created my framework from scratch with help from this tutorial: http://www.raywenderlich.com/65964/create-a-framework-for-ios

多架构构建脚本使我的框架能够在 iOS 模拟器和设备上运行.

The multi-architecture build script is what allowed my framework to run on both the iOS Simulator and a device.

这篇关于Xcode 6 错误 - “缺少必需的架构 i386"为 iOS 模拟器构建时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆