iOS开发中经常遇到的一个错误是Undefined symbols for architecture arm64,这个错误表示工程某些地方不支持arm64指令集。那我们应该怎么解决这个问题了?我们不仅要解决这个问题,更要了解出现这个问题的根源.这样根本上杜绝这类问题发生.

对于iOS设备来说iOS的指令集有armv6、armv7、armv7s、arm64这样四种,不同型号的iOS设备使用不同的指令集,下面是各自的区别:

  • armv6

    • iPhone、iPhone 3G
    • iPod 1G、iPod 2G
  • armv7
    • iPhone 3GS、iPhone 4
    • iPod 3G、iPod 4G、iPod 5G
    • iPad、iPad 2、iPad 3、iPad Mini
  • armv7s
    • iPhone 5、iPhone 5C
    • iPad 4
  • arm64
    • iPhone 5S   iPhone 6   iPhone 6Plus
    • iPad Air, Retina iPad Mini

在Xcode的target->Build Settings中有一个Architectures的分组主要是用来设置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.

Build Active Architectures Only

该编译项用于设置是否只编译当前使用的设备对应的arm指令集。

当该选项设置成YES时,你连上一个armv7指令集的设备,就算你的Valid Architectures和Architectures都设置成armv7/armv7s/arm64,还是依然只会生成一个armv7指令集的二进制包。

当然该选项起作用的前提是你的Xcode必须成功连接了调试设备。如果你没有任何活跃设备,即Xcode没有成功连接调试设备,就算该设置项设置成YES依然还会编译Valid Architectures和Architectures指定的二进制包。

通常情况下,该编译选项在Debug模式都设成YES,Release模式都设成NO。

官方文档说明:

Boolean value. Specifies whether the product includes only object code for the native architecture.

Valid Architectures

该编译项指定可能支持的指令集,该列表和Architectures列表的交集,将是Xcode最终生成二进制包所支持的指令集。

比如将Valid Architectures设置支持的arm指令集版本有:armv7、armv7s、arm64,对应的Architectures设置的支持arm指令集版本有:armv7s,这时Xcode只会生成一个armv7s指令集的二进制包。

官方文档说明:

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.

说明

1、指令集是向下兼容的。比如,armv7s指令集的设备,可以兼容运行使用armv7、armv6编译的程序。

示例

在做项目的时候,用到了第三方社交分享静态库是时候,会编译失败,先来看看下图

看,它忽略了那个静态库文件导致链接失败了,然后我查看了静态库所支持的架构,打开终端输入查看命令lipo - info xxx.a ,结果如下:

发现了这个静态库只支持armv7 armv7s i386 . 而在我的工程中Valid Architectures和Architectures中均包含了arm64的指令集,这就是说明我需要编译的app最终要支持arm64的,而程序中用到的静态库并没有arm64,所以才导致了出错,因此,需要我们去重新下载一个支持arm64的静态库文件,那么就可以正常编译通过了.

参考文档

1、《Xcode设置项之Architectures和Valid Architectures》

2、《xcode5 arm64》

3、《64-Bit Transition Guide for Cocoa Touch》

4、iOS开发之Architectures设置

 

5、Xcode设置项之Architectures和Valid Architectures

Undefined symbols for architecture arm64解决方案的更多相关文章

  1. Undefined symbols for architecture arm64: "_OBJC_CLASS_$_WKWebView", referenced from: objc-c

    出现: Undefined symbols for architecture arm64: "_OBJC_CLASS_$_WKWebView", referenced from: ...

  2. ios集成极光推送:Undefined symbols for architecture arm64: "_dns_parse_resource_record", referenced from:?

    添加libresolv.tbd库,即可解决问题 Undefined symbols for architecture arm64: "_dns_parse_resource_record&q ...

  3. Undefined symbols for architecture arm64: "_OBJC_CLASS_$XXX", referenced from: objc-class-ref in XXX

    ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 ...

  4. iOS Undefined symbols for architecture arm64解决办法

    Undefined symbols for architecture arm64:  "_OBJC_CLASS_$_YYCache", referenced from:      ...

  5. Undefined symbols for architecture arm64:问题

    Undefined symbols for architecture arm64: "_sqlite3_prepare_v2", referenced from: +[HMJSch ...

  6. iOS开发遇到的坑之一: 开发遇见如下错误:Undefined symbols for architecture arm64

    博客处女作,写得不好望谅解! “for architecture arm64”就是说没有支持arm64,在Build settings里architecture相关的几项需要配置正确 在最近升级coc ...

  7. 解决xcode5升级后,Undefined symbols for architecture arm64:问题

    The issue is that the cocoapods have not been built for arm64 architecture yet thus they cannot be l ...

  8. Undefined symbols for architecture arm64:

    1. 没有往项目中导入静态库(.a 文件)需要的 framework. 2.拖到项目中的静态库不支持arm64(或其他)指令集  这种情况没遇到过 一般都是第一种情况.

  9. Undefined symbols for architecture arm64(其cpu架构)

    "_OBJC_CLASS_$_XXX",referenced from: 之类的问题,很多人看到这些很头疼,不知道从何下手去修改.以下是我总结的相关修改办法.如下图 这是一个很明显 ...

随机推荐

  1. 不该活着的SqlHelper和DBHelper

    前言: 还记得刚学ADO.NET的情景么? 还记得当年是怎么从ADO.NET被忽悠到用SqlHelper的么? 话说从入门到走上工作岗位那些年,我们就一直被纯纯地教导或引导,ADO.NET太原始,得封 ...

  2. .Net程序在linux mono环境和WindowsServer上执行测试对比

    最近研究了一下mono,想把windows上写的.Net程序移植到linux上跑.网上有资料说Linux上mono执行.Net程序效率比Windows高,本着实证的态度,只有实际验证过才有说服力. 写 ...

  3. Hadoop3 在eclipse中访问hadoop并运行WordCount实例

    前言:       毕业两年了,之前的工作一直没有接触过大数据的东西,对hadoop等比较陌生,所以最近开始学习了.对于我这样第一次学的人,过程还是充满了很多疑惑和不解的,不过我采取的策略是还是先让环 ...

  4. C#与C++的发展历程第一 - 由C#3.0起

    俗话说学以致用,本系列的出发点就在于总结C#和C++的一些新特性,并给出实例说明这些新特性的使用场景.前几篇文章将以C#的新特性为纲领,并同时介绍C++中相似的功能的新特性,最后一篇文章将总结之前几篇 ...

  5. 使用Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境(一)

    前言     但凡一个略有规模的项目都需要一个持续集成环境的支撑,为什么需要持续集成环境,我们来看一个例子.假如一个项目,由A.B两位程序员来协作开发,A负责前端模块,B负责后端模块,前端依赖后端.A ...

  6. [Intel Edison开发板] 04、Edison开发基于nodejs和redis的服务器搭建

    一.前言 intel-iot-examples-datastore 是Intel提供用于所有Edison开发板联网存储DEMO所需要的服务器工程.该工程是基于nodejs和redis写成的一个简单的工 ...

  7. ABP源码分析二十四:Notification

    NotificationDefinition: 用于封装Notification Definnition 的信息.注意和Notification 的区别,如果把Notification看成是具体的消息 ...

  8. 05.GitHub实战系列~5.发布版本之分支操作+Tag讲解 2015-12-14

    GitHub实战系列汇总:http://www.cnblogs.com/dunitian/p/5038719.html ———————————————————————————————————————— ...

  9. 在SQL Server中为什么不建议使用Not In子查询

        在SQL Server中,子查询可以分为相关子查询和无关子查询,对于无关子查询来说,Not In子句比较常见,但Not In潜在会带来下面两种问题: 结果不准确 查询性能低下       下面 ...

  10. python2.7 内置ConfigParser支持Unicode读写

    1 python编码基础 对应 C/C++ 的 char 和 wchar_t, Python 也有两种字符串类型,str 与 unicode: str与unicode # -*- coding: ut ...