【问题标题】:The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1iOS Simulator 部署目标设置为 7.0,但此平台支持的部署目标版本范围为 8.0 到 12.1
【发布时间】:2019-07-09 07:04:24
【问题描述】:

我在 Xcode 10.1 中收到以下警告消息。

iOS Simulator 部署目标设置为 7.0,但此平台支持的部署目标版本范围为 8.0 到 12.1。

我的模拟器操作系统在 12.1 Xcode 10.1

我更新了我的 pod 文件。

我的部署目标是 9.0

在我的目标中

【问题讨论】:

标签: ios xcode cocoapods ios-simulator google-fabric


【解决方案1】:

您可以设置您的 podfile 以自动将所有 podfile 的部署目标与您当前的项目部署目标匹配,如下所示:

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

【讨论】:

  • 如果您已经有另一个安装后挂钩怎么办?我收到一条错误消息,表明不支持多个后期安装
  • @GeorgeSalamanca,你可以放到同一个 post_install 块中
  • @Fattie 我相信你可以做到config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
  • 我在 podfile 中插入了 sn-p 但它不起作用
  • 嗨@Tao-Nhan Nguyen,我应该在哪里添加它显示的代码?谢谢
【解决方案2】:

问题在于您的 pod 文件部署目标 iOS 版本而不是您的项目部署目标 iOS 版本,因此您需要将 pod 的部署 iOS 版本以及高于 8.0 的任何版本更改为打开项目工作区和这样做:

1- 点击豆荚。

2- 选择每个项目和目标,然后单击构建设置。

3- 在部署部分下,将 iOS 部署目标版本更改为 8.0 以上的版本 (最好尝试相同的项目版本)。

4- 对 pod 中的每个其他项目重复此操作,然后运行应用程序。

详情请看照片

【讨论】:

  • Pods 项目是自动生成的。你不应该惹它。
  • 我没有弄乱吊舱(尽管我发现这样做没有问题,因为它是由人类制造的......)我只是更改了它应该作为目标的 iOS 版本,这是可以接受的。这是一个比公认的更好的解决方案,它迫使您降低自己的项目 iOS 版本。
  • 我并不是说公认的解决方案更好,只是说编辑生成的文件是不好的做法。任何由 Cocoapods 生成的文件都不应手动编辑,因为将来可能会被覆盖。如果您不喜欢输出,您可以通过 post_install 从 Podfile 进行调整。这些文件甚至不应该提交到您的仓库中。
  • @Muhammad 必须由 POD 开发人员自己回答,反正我不会在发布时为我的项目留下任何警告
  • 您可以选择所有这些并一次更改
【解决方案3】:

您可以删除每个 pod 的 pod 部署目标,而不是在 pod post install 中指定部署目标,这会导致部署目标继承自 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

【讨论】:

  • 如果使用此解决方案的任何人遇到fatal error: 'Flutter/Flutter.h' file not found,您可以尝试在installer.pods_project.targets.each do |target| 下添加此行:flutter_additional_ios_build_settings(target)
【解决方案4】:

迭代来自 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

【讨论】:

  • 这为新创建的 react native 应用修复了 100 条 xcode 警告
【解决方案5】:

如果有人从 react native 问题来到这里,只需删除 /build 文件夹并输入 react-native run ios

【讨论】:

  • 这个/build 文件夹在哪里,同事?
  • ./project-root/ios/build
  • 那个目录对我来说不存在,但我刚刚运行cd ios && pod install && cd ..,它又开始工作了。
【解决方案6】:

我们可以将项目部署目标应用到所有 pod 目标。 通过将此代码块添加到 Podfile 的末尾来解决:

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

结果日志:

【讨论】:

  • 不错!彩色原木很有用
【解决方案7】:

我解决了这个问题,我把build systemNew Build System改成了Legacy Build System

在 Xcode v10+ 中,选择文件 > 项目设置

在之前的 Xcode 中,选择 File > Workspace Settings

将构建系统从 New Build System 更改为 Legacy Build System --> 点击完成。

【讨论】:

  • 这不再是适合我的解决方案,因为生成 SwiftUI 预览需要新的构建系统(默认):(
  • 这不是真正的解决方案。
  • 恢复到旧系统不是解决办法
【解决方案8】:

试试这些步骤:

  1. 删除您的 Podfile.lock
  2. 删除您的 Podfile
  3. 构建项目
  4. 从 firebase 添加初始化代码
  5. cd /ios
  6. pod install
  7. 运行项目

这对我有用。

【讨论】:

    【解决方案9】:

    如果您来自 react-native 并遇到此错误,请执行此操作

    1. 打开Podfile(你的项目> ios>Podfile)
    2. 如下注释 podfile 中的翻转器函数
    #use_flipper!
     #post_install do |installer|
       #flipper_post_install(installer)
     #end
    
    1. IOS 文件夹内的终端中输入此命令pod install

    是的,希望它对你有用

    【讨论】:

      【解决方案10】:

      如果有人在更新到最新的 react native 时遇到问题,请尝试使用

      更新您的 pod 文件
        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
      

      【讨论】:

        【解决方案11】:

        Flutter 中对我有用的简单修复:

        1. 删除PodfilePodfile.lock
        2. 运行应用程序:这将创建一个新的Podfile。这可能仍然会因错误而失败。
        3. 在新的Podfile 中,取消注释并将第二行更改为platform :ios, '12.0'(或您要定位的其他最小版本)
        4. 再次运行应用,现在没有错误

        【讨论】:

        • 哇,好久不见了!谢谢!
        【解决方案12】:

        您只需取消注释以下行

        # platform :ios, '8.0'
        

        # platform :ios, '9.0'
        

        等等……

        然后在终端中打开 iOS 文件夹并传递这些命令:

        % pod repo update
        % pod install
        

        【讨论】:

          【解决方案13】:

          对于斯威夫特

          如果您在 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.
          

          发生这种情况是因为已放弃对 iOS 8 的支持,但 pod 的最低部署目标是 iOS 8。

          在解决此问题之前,您可以将以下内容添加到您的 Podfile:

          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

          对于科尔多瓦

          <preference name="deployment-target" value="8.0" />
          

          【讨论】:

            【解决方案14】:

            此解决方案适用于 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
            

            【讨论】:

              【解决方案15】:

              对于遇到此问题的 cordova 开发人员

              尝试设置

              <preference name="deployment-target" value="8.0" />
              

              在 confix.xml 中

              【讨论】:

              【解决方案16】:
              platform :ios, '10.0'
              
              post_install do |installer|
                installer.pods_project.targets.each do |target|
                  flutter_additional_ios_build_settings(target)
                end
                installer.pods_project.targets.each do |target|
                  target.build_configurations.each do |config|
                    config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
                  end
                end
              end
              

              【讨论】:

              • 对我来说,只有将平台更改为 10(+) 后问题才得到解决
              【解决方案17】:

              首先将部署更改为您的选择:例如“11.0” 并将此步骤添加到您的 pod 文件的最后一个

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

              【讨论】:

                【解决方案18】:

                如果有人在将 XCode 更新到 v13 后在 2021 年遇到这个问题,这里有一个对我有用的修复:

                https://github.com/facebook/react-native/issues/31733#issuecomment-924016466

                但是,这可能不适用于所有 react-native 版本,它适用于我的 v0.64。

                我使用 Xcode 创建了虚拟 swift 文件,因此我自动收到了“桥接头”的请求

                希望这将在未来的版本中得到解决。

                【讨论】:

                  【解决方案19】:

                  我在构建 React Native 项目

                  时遇到了同样的问题

                  cocoapods 版本更新对我有用(从 1.8.4 升级到 1.11.2)

                  【讨论】:

                    【解决方案20】:

                    为我工作:

                    rm ios/Podfile
                    flutter pub upgrade
                    flutter pub get
                    cd ios && pod update
                    flutter clean && flutter run
                    sudo arch -x86_64 gem install ffi
                    arch -x86_64 pod install 
                    

                    【讨论】:

                      猜你喜欢
                      • 2019-08-26
                      • 2021-12-01
                      • 2020-10-16
                      • 2021-10-20
                      • 1970-01-01
                      • 2021-10-13
                      • 2021-02-24
                      • 1970-01-01
                      • 1970-01-01
                      相关资源
                      最近更新 更多