将pod文件升级到新的swift版本时出错

问题描述 投票:1回答:2

我的Xcode中有错误:

enter image description here

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')

我发现我应该升级我的swift语言版本,但是当我更新时会显示以下错误:

enter image description here enter image description here

这是我的podfile内容:

platform :ios, '12.1'

target 'Questers' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Questers

pod 'SwiftyJSON'
pod 'TextFieldEffects'
pod 'Alamofire'
pod 'XLPagerTabStrip'
pod 'Eureka' 
pod 'Charts'
pod 'Floaty'
pod 'SVProgressHUD'
pod 'iOSDropDown'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Messaging'
pod 'MessageKit'
pod 'MessageInputBar'

    target 'QuestersUITests' do
    inherit! :search_paths
    pod 'Firebase'
end

结束

ios swift xcode upgrade swifty-json
2个回答
0
投票

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

pod 'Eureka',  '~> 4.3.1'

当您将pod保存在podfile中时,cocoapods会安装最新版本的库。在您的情况下,最新版本是用Swift 5编写的,但是您的xcode不支持Swift 5,您必须设置pod版本以使用受支持的swift版本安装lib。


1
投票

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

解决方案1:

只是

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

对所有3个pod目标重复步骤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手动下载工具链

© www.soinside.com 2019 - 2024. All rights reserved.