将Pod文件升级到新的Swift版本时出错

时间:2019-04-03 09:47:56

标签: ios swift xcode upgrade swifty-json

我的Xcode中有错误:

enter image description here

let currentDate = Date()

let nameFormatter = DateFormatter()
nameFormatter.dateFormat = "MMMM" // format January, February, March, ...

let name = nameFormatter.string(from: currentDate)
let index = Calendar.current.component(.month, from: currentDate) // format 1, 2, 3, ...

print(name)  // April
print(index) // 4

我发现我应该升级自己的快速语言版本,但是更新此错误时会显示:

enter image description here enter image description here

这是我的podfile内容:

SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2.(in target 'SwiftyJSON')
 SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'Eureka')
SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'XLPagerTabStrip')

结束

2 个答案:

答案 0 :(得分:1)

该错误明确表明Swift编译器版本5.0是为 SwiftyJSON,'Eureka','XLPagerTabStrip' pod设置的。

解决方案1:

简单地

  1. 从工作区中选择Pods项目
  2. 从项目目标中选择上述容器。
  3. 在构建设置下搜索Swift语言版本,并将其更新为3.0、4.0或4.2。

对所有3个吊舱目标重复步骤2-3。

将pod的特定配置设置为podfile。

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'Material'
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '4.2'
            end
        end
    end
end

解决方案2:

在这种情况下,如果Pod使用的是Swift 5.0语言功能,则上述解决方案将不起作用。因此,将您的XCode更新为包含Swift 5.0 API的版本10.2。 或从Swift 5.0

手动下载工具链

答案 1 :(得分:0)

将您的Xcode更新为10.2或按如下所示在pod中手动设置版本

pod 'Eureka',  '~> 4.3.1'

将pod放在podfile中时,cocoapods将安装该库的最新版本。 就您而言,最新版本是用Swift 5编写的,但您的xcode不支持Swift 5,则必须设置pod版本以使用受支持的swift版本安装lib。

相关问题