React Native iOS执行pod install遇OpenSSL-Universal版本兼容问题求助
问题:CocoaPods依赖冲突(OpenSSL-Universal版本不兼容)
背景
执行pod install时收到警告:
[!] use_flipper is deprecated, use the flipper_configuration option in the use_react_native function
按照提示修改Podfile,将use_flipper!替换为use_flipper!({ 'Flipper-Folly' => '2.3.0' }),删除Podfile.lock后重新执行pod install,出现以下错误:
[!] CocoaPods could not find compatible versions for pod "OpenSSL-Universal": In Podfile: Flipper-Folly (= 2.3.0) was resolved to 2.3.0, which depends on OpenSSL-Universal (= 1.0.2.20) OpenSSL-Universal (= 1.1.1100) Specs satisfying the `OpenSSL-Universal (= 1.1.1100), OpenSSL-Universal (= 1.0.2.20)` dependency were found, but they required a higher minimum deployment target.
当前iOS部署目标为13.0,调整部署目标后仍无法解决问题,附上当前Podfile内容:
require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '13.0' install! 'cocoapods', :deterministic_uuids => false target 'XXApp' do config = use_native_modules! # Flags change depending on the env values. flags = get_default_flags() use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) pod 'react-native-beacons-manager', :path => '../node_modules/react-native-beacons-manager' target 'XXAppTests' do inherit! :complete # Pods for testing end # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. use_flipper!({ 'Flipper-Folly' => '2.3.0' }) post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end
解决方案
方案1:使用官方推荐的flipper_configuration配置
根据警告提示,use_flipper已废弃,应在use_react_native!中配置flipper_configuration参数,替代单独调用use_flipper!。修改Podfile如下:
use_react_native!( :path => config[:reactNativePath], :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], :app_path => "#{Pod::Config.instance.installation_root}/..", # 添加flipper配置 :flipper_configuration => FlipperConfiguration.enabled(['Flipper-Folly' => '2.3.0']) )
同时删除原来单独的use_flipper!({ 'Flipper-Folly' => '2.3.0' })行。
方案2:升级Flipper-Folly到兼容版本
Flipper-Folly 2.3.0依赖的OpenSSL版本较老,与项目中其他依赖的1.1.1100版本冲突。可以升级Flipper-Folly到更高版本(如2.6.0+,这类版本已适配OpenSSL 1.1.x系列):
# 对应方案1的配置修改 :flipper_configuration => FlipperConfiguration.enabled(['Flipper-Folly' => '2.6.0']) # 若暂时保留use_flipper!(不推荐,因已废弃) use_flipper!({ 'Flipper-Folly' => '2.6.0' })
方案3:强制统一OpenSSL版本
如果上述方案无效,可在Podfile的post_install块中添加配置,强制所有依赖使用同一版本的OpenSSL,并适配部署目标:
post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) # 强制OpenSSL-Universal使用1.1.1100版本并适配部署目标 installer.pods_project.targets.each do |target| target.build_configurations.each do |config| if target.name == 'OpenSSL-Universal' config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' end end end end
通用操作步骤
每个方案执行后都需要完成以下步骤:
- 删除
Podfile.lock文件 - 删除
Pods文件夹 - 执行
pod repo update更新本地pod仓库 - 执行
pod install重新安装依赖
内容的提问来源于stack exchange,提问作者iSaBo
相关产品推荐
相关产品推荐

