美文网首页
Xcode does not contain bitcode

Xcode does not contain bitcode

作者: OnceChange | 来源:发表于2023-02-16 19:41 被阅读0次

问题描述

通过 Cocoapods 在接入一个第三方库,pod install 之后,Xcode 出现了下图错误。

error.png

错误描述如下:

ld: 'xxx' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. 'xxx' for architecture arm64

问题原因:
有些三方库不支持 Bitcode,如果项目中开启了 Enable Bitcode,就会出错。解决方法:要么是换为支持 Bitcode 的库,要么修改 Xcode 设置。

大多数情况下,换三方库都不太可能实现。所以一般是修改 Xcode 设置。

解决方法

查阅了一下资料,解决方法一般有两种。

1. 设置Xcode 的 Enable Bitcode 为 NO

通过 Target -> BuildSettings -> Enable Bitcode,设置为 NO。

bitcode.jpg

一般情况下,这种解决方法就能解决问题了。

2. 修改 Podfile 文件

方法 1 没有解决我的问题,甚至重启电脑后问题依然存在。在 stackoverflow 找到了方法 2 ,解决了我的问题。

在 Podfile 文件中添加:config.build_settings['ENABLE_BITCODE'] = 'NO'

比如:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

相关文章

网友评论

      本文标题:Xcode does not contain bitcode

      本文链接:https://www.haomeiwen.com/subject/uynpkdtx.html