【问题标题】:Cocoapods 1.1.0 beta for Swift3Swift3 的 Cocoapods 1.1.0 beta
【发布时间】:2016-09-14 21:21:45
【问题描述】:

使用 Swift3 升级到 Xcode8 后,我发现 Cocoapods 不再支持这个了。所以我将 Cocoapods 升级到 beta 版本,即 1.1.0rc2。但是当我尝试 pod spec lint 时,发生了错误:

- ERROR | xcodebuild:  WeatherKit/WeatherKit/DateComponents+InitFromString.swift:11:11: error: use of undeclared type 'DateComponents'
- ERROR | [iOS] xcodebuild:  WeatherKit/WeatherKit/CityLoader.swift:14:13: error: use of undeclared type 'DispatchQueue'
- ERROR | [iOS] xcodebuild:  WeatherKit/WeatherKit/CityLoader.swift:19:11: error: use of unresolved identifier 'DispatchQueue'
- WARN  | [iOS] xcodebuild:  WeatherKit/WeatherKit/DirectionUnit.swift:20:15: warning: extraneous '_' in parameter: 'value' has no keyword argument name
- WARN  | [iOS] xcodebuild:  WeatherKit/WeatherKit/DistanceUnit.swift:19:15: warning: extraneous '_' in parameter: 'value' has no keyword argument name

Analyzed 1 podspec.

[!] The spec did not pass validation, due to 20 errors and 2 warnings.

这 20 个错误都是关于 Swift3 语法的。但我使用的是 Xcode8,它应该允许所有这些语法

有人知道我可以用这个做什么吗?

【问题讨论】:

    标签: cocoapods swift3


    【解决方案1】:

    我会尝试回到旧版本并将 podFile 保留为 iOS 9 而不是 iOS 10。我假设此错误是 CocoaPods 测试版中的错误。

    【讨论】:

    • 但是当我回滚时,会显示“- ERROR | [iOS] unknown: Encountered an unknown error (Simulator iPhone 4s is not available.) during validation.”
    • 我不认为 iPhone 4S 是 Xcode 8 sim 中的一个选项(或者它不应该是)。尝试使用 iPhone SE。
    • 但它不适用于 Cocoapods。试过把模拟器换成iPhone5,还是不行。不过已经解决了,看我上面的回答
    【解决方案2】:

    我用1.1.0rc2版本解决了这个问题。

    问题是因为s​​wift编译版本不对,默认是2.3,但是代码是3.0。

    所以修改validator.rb:

    # @return [String] the SWIFT_VERSION to use for validation.
    #
    def swift_version
      @swift_version ||= dot_swift_version || '2.3'
    end
    

    # @return [String] the SWIFT_VERSION to use for validation.
    #
    def swift_version
      @swift_version ||= dot_swift_version || '3.0'
    end
    

    问题解决了

    【讨论】:

      猜你喜欢
      • 2017-02-03
      • 1970-01-01
      • 2015-08-28
      • 2013-01-14
      • 2021-01-23
      • 2016-04-06
      • 2021-03-05
      • 2021-11-26
      • 2011-04-26
      相关资源
      最近更新 更多