您可以这样设置podfile以自动匹配所有podfiles的部署目标与当前项目部署目标:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
即可。 - rmp251不要在 pod post install 中指定部署目标,而是删除每个 pod 的部署目标,这会导致从 Podfile
继承部署目标。
您可能需要运行 pod install
以使其生效。
platform :ios, '12.0'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
在遍历Tao-Nhan Nguyen所回答的内容时,考虑每个Pod的原始值集合,仅当其小于8.0时进行调整... 将以下内容添加到Podfile中:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if Gem::Version.new('8.0') > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
end
end
end
end
post_install do |installer|
fix_deployment_target(installer)
end
def fix_deployment_target(installer)
return if !installer
project = installer.pods_project
project_deployment_target = project.build_configurations.first.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
puts "Make sure all pods deployment target is #{project_deployment_target.green}"
project.targets.each do |target|
puts " #{target.name}".blue
target.build_configurations.each do |config|
old_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
new_target = project_deployment_target
next if old_target == new_target
puts " #{config.name}: #{old_target.yellow} -> #{new_target.green}"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = new_target
end
end
end
结果日志:
如果有人从React Native的问题出发,请删除/build文件夹并输入react-native run ios
/build
文件夹在哪里,同事? - Erik Escobedocd ios && pod install && cd ..
,然后它又恢复正常了。 - Jimbalicd /ios
pod install
我用这个方法解决了Flutter的问题。打开{your_project_root_folder}/ios/Podfile
文件并用以下代码替换post_install块:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
针对Swift语言
如果你正在使用Xcode 12和CocoaPods,那么你可能会遇到下面的错误:
The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
这将从您项目中的所有Pod中删除部署目标,并允许它们继承在Podfile顶部指定的项目/工作区部署目标。
对于React Native
删除./project-root/ios/build文件夹,然后输入react-native run ios
对于Cordova
<preference name="deployment-target" value="8.0" />
use_flipper!
post_install do |installer|
flipper_post_install(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
Xcode
,在苹果图标的左上方找到File
,然后打开Workspace Settings
并将构建系统更改为Legacy Build System
。如果你还没有尝试过这个方法,可以查看这个网址的答案:https://dev59.com/oVQK5IYBdhLWcg3wDLvP#52552878 - Vinaykrishnan