首页 > 解决方案 > 每次 pod 更新时 SWIFT_VERSION 错误

问题描述

每次我更新 Podfile 时,都必须修复这个 SWIFT_VERSION 错误才能解决。

如何将 pod 和 swift 版本设置为唯一,以便每次更新 pod 时无需修复 SWIFT_VERSION 错误。

Error: SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2.  (in target 'paper-onboarding')

由于操作系统的限制,X-Code 允许 swift 最多运行 4.2。

Swift 5.0 将不支持,必须将其降至 4.2 版本才能兼容并在模拟器或设备上运行应用程序。

标签: iosswiftcocoapods

解决方案


将此添加到您的Podfile. 在里面插入你想要的 pod{pod-name}并设置你需要的版本

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == '{pod-name}'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.0'
      end
    end
  end
end

推荐阅读