Ios Cocoapods:如何使用最新的Swift版本创建pod?

Ios Cocoapods:如何使用最新的Swift版本创建pod?,ios,cocoapods,Ios,Cocoapods,我正在学习如何使用Cocoapods创建pod,因此我运行了以下命令: pod lib create {my_pod_name} 使用iOS平台、Swift语言,包括我的库中的演示应用程序,不使用任何测试框架或基于视图的测试 但是,在打开项目时,我收到了警告: 可转换为Swift 4.2 这就是我在构建设置中看到的: 那么为什么会发生这种情况呢 谢谢你的帮助 如果我正确理解了你的问题,Swift版本由 更详细地说,它看起来像: Pod::Spec.new do |spec| ...

我正在学习如何使用Cocoapods创建pod,因此我运行了以下命令:

pod lib create {my_pod_name}
使用iOS平台、Swift语言,包括我的库中的演示应用程序,不使用任何测试框架或基于视图的测试

但是,在打开项目时,我收到了警告:

可转换为Swift 4.2

这就是我在构建设置中看到的:

那么为什么会发生这种情况呢


谢谢你的帮助

如果我正确理解了你的问题,Swift版本由

更详细地说,它看起来像:

Pod::Spec.new do |spec|
  ...
  spec.swift_version = '4.2'
  ...
end
我假设如果不考虑这一点,它当前默认为4.0

如果您想了解更多详细信息,请查看:


显示您的podspec。如果您还没有这样做,请添加行
s.swift\u version='4.2'
(假设
s
是您的规范)谢谢您的回答,但我的问题更像是:当我第一次创建默认swift版本为4.0的pod时,实际是什么决定的?您当前的cocoapod版本是什么?我认为当前的cocoapod创建了一个Xcode 9项目,而不是Xcode 10,因此它默认使用Swift 4.0(请参见此处:)谢谢您的回答。是的,我知道我可以通过将
swift\u版本指定到
podspec
中来选择
swift\u版本,但我想知道的是,如果
podspec
中没有指定,是什么决定了默认的
swift\u版本是4.0?您可以在源代码中检查版本实现:
# @return [String] the Swift version for the target. If the pod author has provided a set of Swift versions
#         supported by their pod then the max Swift version across all of target definitions is chosen, unless
#         a target definition specifies explicit requirements for supported Swift versions. Otherwise the Swift
#         version is derived by the target definitions that integrate this pod as long as they are the same.
#
def swift_version
  @swift_version ||= begin
    if spec_swift_versions.empty?
      target_definitions.map(&:swift_version).compact.uniq.first
    else
      spec_swift_versions.sort.reverse_each.find do |swift_version|
        target_definitions.all? do |td|
          td.supports_swift_version?(swift_version)
        end
      end.to_s
    end
  end
end