'pod spec lint' fails after project conversion to Swift 4

1.2k Views Asked by At

After converting my cocoa framework project to Swift 4 the class UIFontDescriptorFamilyAttribute is now UIFontDescriptor.AttributeName.family, so I changed my code from:

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

to

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

However, when I try -pod spec lint- I get next error:

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

Is cocoapods somehow not aware yet of Swift 4? Do I have to update something else in my configuration?

My config:

.podspec

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

cocoapods

$ pod --version
1.3.1
2

There are 2 best solutions below

0
On BEST ANSWER

Try to make a file named .swift-version and inside just put 4.0

Update for Cocoapods >= 1.5

you now use s.swift_version = '4.1' in your podspec

1
On

To lint for different versions of Swift:

With CocoaPods 1.3.1 or newer

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

With CocoaPods 1.4.0 or newer

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