【问题标题】:'pod spec lint' fails after project conversion to Swift 4项目转换为 Swift 4 后,“pod spec lint”失败
【发布时间】:2018-03-05 14:13:01
【问题描述】:

将我的 cocoa 框架项目转换为 Swift 4 后,类 UIFontDescriptorFamilyAttribute 现在是 UIFontDescriptor.AttributeName.family ,所以我将代码更改为:

// Swift 3    
UIFontDescriptor(fontAttributes: [UIFontDescriptorFamilyAttribute: fontFamiliy])

// Swift 4
UIFontDescriptor(fontAttributes: [UIFontDescriptor.AttributeName.family: fontFamiliy])

但是,当我尝试 -pod spec lint- 我得到下一个错误:

- ERROR | [iOS] xcodebuild:  SerializableLabel.swift:108:68: error: type 'UIFontDescriptor' has no member 'AttributeName'

cocoapods 不知何故还不知道 Swift 4?我是否必须更新配置中的其他内容?

我的配置:

.podspec

s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }

可可足类

$ pod --version
1.3.1

【问题讨论】:

标签: swift cocoapods swift4 uifontdescriptor


【解决方案1】:

尝试创建一个名为 .swift-version 的文件,在里面放 4.0

Cocoapods 更新 >= 1.5

您现在在 podspec 中使用 s.swift_version = '4.1'

【讨论】:

    【解决方案2】:

    为不同版本的 Swift 进行 lint:

    使用 CocoaPods 1.3.1 或更新版本

    # example for Swift 4.0
    echo "4.0" > .swift-version
    pod lib lint
    

    使用 CocoaPods 1.4.0 或更新版本

    # example for Swift 4.0
    pod lib lint --swift-version=4.0
    

    【讨论】:

    • 我也爱你!哈哈谢谢!
    猜你喜欢
    • 1970-01-01
    • 2019-10-02
    • 1970-01-01
    • 1970-01-01
    • 2019-03-18
    • 1970-01-01
    • 1970-01-01
    • 2015-11-21
    • 1970-01-01
    相关资源
    最近更新 更多