SwiftDate 5.0 compilation issues

708 Views Asked by At

When I install SwiftDate through Cocoapods and try to build my project, I get three errors from the SwiftDate library:

/Pods/SwiftDate/Sources/SwiftDate/DateInRegion/DateInRegion.swift:11:15: Type 'DateInRegion' does not conform to protocol 'Hashable'

/Pods/SwiftDate/Sources/SwiftDate/DateInRegion/DateInRegion+Create.swift:50:33: Type 'UInt32' has no member 'random'

/Pods/SwiftDate/Sources/SwiftDate/DateInRegion/DateInRegion+Create.swift:65:37: Type 'UInt32' has no member 'random'

Am I using an incorrect version of SwiftDate, Swift, or XCode? When I try to install SwiftDate 4.5.1, I get no errors in the library but none of the SwiftDate functions actually work.

2

There are 2 best solutions below

4
Robert Dresler On BEST ANSWER

Since versions 5.0.0+ of SwiftDate include code from Swift 4.2, you have to have installed Xcode which supports this version of Swift (Xcode 10+).

Otherwise you can use the latest version of SwiftDate which doesn't use code from Swift 4.2 such as getting random number easily (SwiftDate 4.5.0) by specifing the version of cocoapod in podfile

pod 'SwiftDate', '4.5.0'
0
Mosbah On

As per SwiftDate release notes the latest version is using Swift 4.2 (starting from 5.0.9) so I assume that you are using an older version of Swift.

Otherwise check the migration guide for more informations. https://github.com/malcommac/SwiftDate/blob/master/Documentation/10.Upgrading_SwiftDate4.md