简体   繁体   中英

SwiftDate 5.0 compilation issues

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.

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

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM