2

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
juliancadi
  • 987
  • 1
  • 8
  • 23

2 Answers2

9

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

HaneTV
  • 916
  • 1
  • 7
  • 24
1

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
Cœur
  • 37,241
  • 25
  • 195
  • 267