使用CocoaPods时出现Xcode 12部署目标警告

dphi5xsq  于 2022-11-17  发布在  其他
关注(0)|答案(7)|浏览(143)

我在Xcode 12上收到以下警告:
iOS Simulator部署目标IPHONEOS_DEPLOYMENT_TARGET设置为8.0,但支持的部署目标版本范围为9.0到14.0.99
如何支持此版本?

ukqbszuj

ukqbszuj1#

这里有一个简短的解决方案!只需将代码片段复制并粘贴到Podfile的末尾,然后运行pod install命令。

post_install do |installer|
     installer.pods_project.targets.each do |target|
         target.build_configurations.each do |config|
            if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 12.0
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
            end
         end
     end
  end

在这种情况下,12.0是AppStore提交的最低支持iOS版本。您可以根据项目要求更改此版本。

u2nhd7ah

u2nhd7ah2#

这是一个目标在你的可可豆荚上的问题。对我来说,答案是把下面的代码放在你的豆荚文件的结尾:

post_install do |installer|
     installer.pods_project.targets.each do |target|
         target.build_configurations.each do |config|
             config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'
             config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
             config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
         end
     end
  end

它解决了我所有的问题,编译和存档的项目。
另一种方法是更改pod项目中的IPHONEOS_DEPLOYMENT_TARGET,如下图所示:


此致。

0dxa2lsx

0dxa2lsx3#

更新:要解决此问题,您只需将Deployment Target更新为9.0。更新方法是打开.xcworkspace文件,选择Xcode上的Pods.xcodeproj,然后将iOS Deployment Target更新为9.0或更高版本,如下图所示。

另一个简单的修复方法是将以下代码添加到您的Podfile中,并在终端上的目录中运行pod install

post_install do |installer|
 installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
     if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 9.0
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
     end
   end
 end
end

Previous:除非导入支持文件,否则您无法在Xcode 12上为iOS 8.0提供支持。要默认提供支持,您必须使用Xcode 11。最好检查在iOS 8上使用您的应用的用户数量,并将最低支持版本更新为iOS 9或更高版本。

3qpi33ja

3qpi33ja4#

Flutter现在需要一条额外的生产线,以便在2021年底之前工作。
将下面更新的代码片段粘贴到Podfile的末尾,然后运行pod install命令。

post_install do |installer|
     installer.pods_project.targets.each do |target|
         flutter_additional_ios_build_settings(target)
         target.build_configurations.each do |config|
            if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 10.0
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
            end
         end
     end
  end

**注:**如果您的podfile中有以下代码,请将其替换为以上代码。

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
r1zk6ea1

r1zk6ea15#

这是因为Xcode 12中已不再支持iOS 8,但违规Pod的最低 * 部署 * 目标仍然是iOS 8。这在Xcode 12 release notes中有记录:

过时

  • Xcode现在支持在运行iOS 9.0及更高版本的iOS设备上调试应用程序和运行测试。
    解决方法。您可以将以下内容附加到您的Podfile中作为暂时的解决方法(然后照常运行pod install):
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 9.0
        config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      end
    end
  end
end

这将从所有使用iOS 8或更低版本的单元中移除部署目标设置,允许它们简单地继承您在Podfile顶部指定的项目部署目标。例如:

platform :ios, '10.0'
kkbh8khc

kkbh8khc6#

我还需要加上

s.platform = :ios, "9.0"

我的**.podspec**文件,以及上述(或以下)答案中的post_install脚本。
注:S.平台为

s.platform = :ios
tquggr8v

tquggr8v7#

我使用Flutter,因此我的步骤:
1.删除Podfile.lock文件
1.更改为平台:ios,“10.0”
1.删除ios文件夹中的Pod文件夹
1.后藤终端和Pod安装所有内容

相关问题