Archive Invalid Bitcode Signature 错误不能通过设置 Release Build Active Architecture Only 为 YES 来解决

Archive Invalid Bitcode Signature 错误不能通过设置 Release Build Active Architecture Only 为 YES 来解决

    今天在项目中遇到了这个问题。这也不是第一次遇到了。之前使用的解决方案都没能奏效,包括 Clean、Delete Derived Data、重启 Xcode 以及检查是不是有别的错误提示。后来,尝试设置 Release Build Active Architecture Only 为 YES,Archive 成功。但是这样做其实只治标,不治本,还会带来严重问题。下面具体说说问题的表现、我的排查过程以及最后的解决方法。

1. 问题表现

    Run 可以成功。Archive 失败。设置 Release Build Active Architecture Only 为 YES,Archive 可以成功。深入一下,我的 Scheme 设置中,Run 使用 Debug Build Configuration,Archive 使用的是 Release Build Configuration,和默认的一样。而 Debug Build Configuration 的 Build Active Architecture Only 默认是 YES,目的是不生成 Universal Binary(也叫 Fat Binary),只生成适用于你要调试的机器的这一种 CPU 架构(arm64或者armv7s或者armv7)的产物,构建速度更快。Release Build Configuration 的 Build Active Architecture Only 默认是 NO,目的是生成 Universal Binary,可以运行在各种各样 CPU 架构的机型上。强行通过设置 Release Build Active Architecture Only 为 YES 解决 Invalid Bitcode Signature 错误会带来新的问题,构建产物无法运行在各种 CPU 架构的机型上,这是严重问题。各种机型 CPU 架构如下,参考这里

  • arm64 is the current 64-bit ARM CPU architecture, as used since the iPhone 5S and later (6, 6S, SE and 7), the iPad Air, Air 2 and Pro, with the A7 and later chips.
  • armv7s (a.k.a. Swift, not to be confused with the language of the same name), being used in Apple’s A6 and A6X chips on iPhone 5, iPhone 5C and iPad 4.
  • armv7, an older variation of the 32-bit ARM CPU, as used in the A5 and earlier.
2. 问题排查

    虽然不能把 Build Active Architecture Only 设置为 YES 来解决问题,但是这个方案提供了一个思路,Archive 应该是因为构建某一 CPU 架构产物的时候失败了而失败的。我修改 Valid Architecture ,让它只包含 arm64 时,Archive 可以成功。说明是构建 armv7、armv7s 产物的时候失败的。这个时候,情况已经明朗了,打概率是因为依赖的某个 library 不包含 armv7、armv7s 产物导致的。可以用 lipo -info xxx.a 命令可以查看你的库支持哪些架构(参考)。Framework 其实就是一个文件夹,文件夹里面也有 .a 文件,只不过后缀名省略了,你可以这样查看它支持哪些架构,lipo -info TesseractOCR.framework/TesseractOCR,(我 Archive 失败的罪魁祸首就是这个 TesseractOCR.framework 了)。

3. 问题解决

    找到罪魁祸首之后,删除它或者替换它。一般不会再出问题。我的过程稍微曲折一些,也是因为情况复杂,导致我删除了未生效。情况复杂在我的主工程依赖一个 Development Pod (pod ‘XXX’, :path => “./XXX”),Development Pod 依赖 Tesseract (s.vendored_frameworks = ‘NlsClientSDK.framework’, ‘opencv2.framework’, ‘TesseractOCR.framework’),我把 TesseractOCR.framework 从中删除之后,Archive 还是没有成功,因为没有 Pod install,xcconfig 里面 OTHER_LDFLAGS 里面还是有对 TesseractOCR.framework 的依赖。

    问题解决,加深了对 iOS 构建过程的了解,还要继续加强。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值