安装新 pod 时更改目标 ios 版本
Change target ios version when installing new pod
每当我安装一个新的 pod 项目时,例如我安装 firebase 库,我总是安装针对项目 8.0 的库,或者我开始手动将它们更改为 9.0 或 14.0,因为警告我' m 获取.
Podfile 内容如下:
platform :ios, '14.0'
target 'TestProject' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TestProject
pod 'SDWebImageSwiftUI'
pod 'lottie-ios'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
end
如何一次更新目标 iOS,这样我就不会一个一个地更新所有库?
将此添加到您的 Podfile
,然后 pod install
。
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
end
end
这会立即将所有 Pod 目标更新为您想要的版本。
根据您的 Podfile,Warren 的回答可能不足以将所有目标设置为新的部署目标。我推荐使用这个 post-install handler:
deployment_target = '14.0'
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end
end
project.build_configurations.each do |bc|
bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end
end
end
当您使用 install! 'cocoapods', :generate_multiple_pod_projects => true
等选项时,此添加变得很重要
每当我安装一个新的 pod 项目时,例如我安装 firebase 库,我总是安装针对项目 8.0 的库,或者我开始手动将它们更改为 9.0 或 14.0,因为警告我' m 获取.
Podfile 内容如下:
platform :ios, '14.0'
target 'TestProject' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TestProject
pod 'SDWebImageSwiftUI'
pod 'lottie-ios'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
end
如何一次更新目标 iOS,这样我就不会一个一个地更新所有库?
将此添加到您的 Podfile
,然后 pod install
。
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
end
end
这会立即将所有 Pod 目标更新为您想要的版本。
根据您的 Podfile,Warren 的回答可能不足以将所有目标设置为新的部署目标。我推荐使用这个 post-install handler:
deployment_target = '14.0'
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end
end
project.build_configurations.each do |bc|
bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end
end
end
当您使用 install! 'cocoapods', :generate_multiple_pod_projects => true