问题

开发环境:xcode6,iPhone6模拟器

xcode工程编译错误:No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).

原因

导致这个错误的原因主要是CPU的编译架构引起的,Build Active Architecture Only属性设置为了YES(只编译当前模拟器指令集),当出现不兼容设备时就会出现错误。

解决

在工程Build Settings,设置Build Active Architecture Only属性设置为NO,并且Architectures与Valid Architectures属性分别添加ARMv7,ARMv7s,ARM64值,clear工程,重新build即可。

首先我们先了解一下各类型iOS设备的架构:

ARMv8/ARM64 = iPhone 5s, iPad Air, Retina iPad Mini 
ARMv7s = iPhone 5, iPhone 5c, iPad 4 
ARMv7  = iPhone 3GS, iPhone 4, iPhone 4S, iPod 3G/4G/5G, iPad, iPad 2, iPad 3, iPad Mini   
ARMv6  = iPhone, iPhone 3G, iPod 1G/2G (一般不需要去支持)

要解决这个错误,应该关注以下几个属性设置:

1.Build Active Architecture Only属性

设置为yes时,只编译当前的设备(architecture)版本,提高debug是的编译速度;

设置为no时,会编译所有的版本(发布release时使用,以兼容各类型设备)。

注:编译出的版本是向下兼容的,比如你设置此值为yes,用iphone4编译出来的是armv7版本的,iphone5也可以运行,但是armv6的设备就不能运行。

2.Architectures与Valid Architectures区别及联系

Architectures引用苹果文档解释:

Space-separated list of identifiers. Specifies the architectures (ABIs, processor models) to which the binary is targeted. When this build setting specifies more than one architecture, the generated binary may contain object code for each of the specified architectures.

简单来说就是工程被编译成可支持哪些指令集类型,而支持的指令集越多,对应生成二进制包就越大,也就是ipa包会变大。

Valid Architectures苹果文档解释:

Space-separated list of identifiers. Specifies the architectures for which the binary may be built. During the build, this list is intersected with the value of ARCHS build setting; the resulting list specifies the architectures the binary can run on. If the resulting architecture list is empty, the target generates no binary.

有效编译指令集,也就是Xcode编译出来的二进制包类型最终从这些类型产生,而编译出哪种指令集的包,将由Architectures与Valid Architectures(因此这个不能为空)的交集来确定,例如:
比如,你的Valid Architectures设置的支持arm指令集版本有:armv7/armv7s/arm64,对应的Architectures设置的支持arm指令集版本有:armv7s,这时Xcode只会生成一个armv7s指令集的二进制包。

编译集选择
如果你对ipa安装包大小有要求,可以减少安装包的指令集的数量,这样就可以尽可能的减少包的大小。当然这样做会使部分设备出现性能损失,当然在普通应用中这点体现几乎感觉不到,至少不会威胁到用户体检(这就跟win7系统在32位和64位运行QQ一样,你看得出么?)。或者你也还在担心这个问题,你可以把百度地图等SDK下载下来,使用lipo、ar等命令查看一下它们的编译架构。
注:不过,新版的app审核规则中,似乎已经逐渐要求app必须支持64位的设备,因此在今后的工程维护中得多关注解决兼容性问题。

参考文章:Xcode设置项之Architectures和Valid Architectures

xcode工程编译错误:No architectures to compile for的更多相关文章

  1. Xcode工程编译错误之iOS开发之Xcode9报错 Compiling IB documents for earlier than iOS7 is no longer supported.

    概要: 在我们升级到Xcode9时,最低的编译版本为iOS8,但是在使用一些SDK的时候就会报出Compiling IB documents for earlier than iOS7 is no l ...

  2. xcode工程编译错误:一般错误总结

    1.Apple LLVM 8.0 Error Group /’all-product-headers.yaml’ not found 最近升级了xcode打包后出现了个BUG,记录解决的方法. 现象: ...

  3. xcode工程编译错误:missing required architecture i386 解决方法

    可能原因一:项目内保存了.framework文件,在复制分发到不同计算机的时候可能会引发该错误 解决方法一:来到Targets->Build Settings->Framework Sea ...

  4. Xcode工程编译错误:“Cannot assign to 'self' outside of a method in the init family”

    #import <Foundation/Foundation.h> @interface EOCRectangle : NSObject<NSCoding> @property ...

  5. Xcode工程编译错误之iOS开发之The Xcode build system has crashed. Please close and reopen your workspace

    解决方法: . 删除DerivedData . 参照上面的链接设置:File -> Workspace Settings -> Build System -> Legacy Buil ...

  6. xcode工程编译错误:error: Couldn’t materialize

    错误信息: error: Couldn't materialize: couldn't get the value of variable amount: variable not available ...

  7. xcode工程编译错误:The maximum number of apps for free development profiles has been reached.

    真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...

  8. Xcode工程编译错误之iOS开发之Sending '__strong typeof (xxx)' (aka 'xxxx *__strong') to parameter of incompatible type 'id<xxx>'

    iphone开发出现警告: Sending '__strong typeof (xxx)' (aka 'xxxx *__strong') to parameter of incompatible ty ...

  9. xcode工程编译错误之iOS解决CUICatalog: Invalid asset name supplied问题

    [问题分析]: 这个问题其实是老问题,产生原因就是因为在使用的时候 [UIImage imageNamed:]时,图片不存在或者传入的图片名为nil. [解决方法]: 添加一个系统断点,来判断如果图片 ...

随机推荐

  1. cocos2d-x 弹出对话框

    登陆界面有一点注册按钮,点击之后弹出一个框,让用户输入一些信息; 在网上找的一些方法都是派生一个类,然后自己实现; 我觉得太麻烦了. 我使用分层的方式来显示, 启动界面就一个,背景图片加几个按钮:登陆 ...

  2. python的httplib、urllib和urllib2的区别及用

    慢慢的把它们总结一下,总结就是最好的学习方法 宗述 首先来看一下他们的区别 urllib和urllib2 urllib 和urllib2都是接受URL请求的相关模块,但是urllib2可以接受一个Re ...

  3. iOS开发--时间戳问题

    什么是时间戳? 时间戳(timestamp),通常是一个字符序列,唯一地标识某一刻的时间.数字时间戳技术是数字签名技术一种变种的应用. 思考:简单来讲就是根据文件hash加密后生成的摘要和时间生成的时 ...

  4. 编译poco-1.7.8

    运行build_vs140.cmd,运行之前可以修改一些参数,例如编译64位 buildwin 140 build shared both x64 nosamples notests devenv 修 ...

  5. centos7/nginx/tornado错误异常收集

    临时方法 – 设置系统参数 使用命令setenforce 附: setenforce 设置SELinux 成为enforcing模式 setenforce 设置SELinux 成为permissive ...

  6. 《C++ Primer Plus》第17章 输入、输出和文件 学习笔记

    流是进出程序的字节流.缓冲区是内存中的临时存储区域,是程序与文件或其他I/O设备之间的桥梁.信息在缓冲区和文件之间传输时,将使用设备(如磁盘驱动器)处理效率最高的尺寸以大块数据的方式进行传输.信息在缓 ...

  7. eclipse闪退解决

    log: !SESSION 2014-03-12 14:02:45.207 -----------------------------------------------eclipse.buildId ...

  8. 《转载》WIN10 64位系统 32位Python2.7 PIL安装

    http://blog.csdn.net/kanamisama0/article/details/53960281 首先安装这个真的出了好多问题,之前装过一次PIL也失败了,就一直没管,今天刚好找了机 ...

  9. Get方法和post方法有何不同?

    Get方法和post方法有何不同? 在B/S应用程序中,前台与后台的数据交互,都是通过HTML中Form表单完成的.Form提供了两种数据传输的方式——get和post.虽然它们都 是数据的提交方式, ...

  10. php API接口入门

    1.简述: api接口开发,其实和平时开发逻辑差不多:但是也有略微差异: 平时使用mvc开发网站的思路一般是都 由控制器 去 调用模型,模型返回数据,再由控制器把数据放到视图中,展现给用户: api开 ...