1

将我的可可框架项目转换为 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
4

2 回答 2

8

尝试制作一个名为 .swift-version 的文件,然后在里面放 4.0

更新 Cocoapods >= 1.5

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

于 2017-09-27T17:02:19.363 回答
1

为不同版本的 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
于 2017-09-27T17:21:17.507 回答