1

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.

user28434'mstep
  • 6,290
  • 2
  • 20
  • 35
Nolan Gelinas
  • 53
  • 1
  • 8
  • What versions of XCode and Swift are you using? – user28434'mstep Jan 14 '19 at 14:35
  • @user28434 XCode 9.4 and Swift 4.1. I installed SwiftDate 4.5 as Robert Dresler suggested, but as far as I can tell none of the functions work correctly. I feel like I am importing the wrong thing to my file... I can't find what I am supposed to import in the installation guide though. – Nolan Gelinas Jan 14 '19 at 17:12

2 Answers2

0

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

Mosbah
  • 1,347
  • 1
  • 14
  • 28
0

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'
Robert Dresler
  • 10,580
  • 2
  • 22
  • 40
  • Ok so I had done that before but none of the functions listed in the documentation worked. It just says they are unrecognized functions so I assumed that it did not install correctly. Is there separate documentation for SwiftDates 4.5? for example: `let date1 = DateInRegion("2016-01-05", format: "yyyy-MM-dd", region: regionNY)` returns: `Use of unresolved identifier 'DateInRegion'` and `Use of unresolved identifier 'regionNY'` – Nolan Gelinas Jan 14 '19 at 16:48
  • @NolanGelinas https://github.com/malcommac/SwiftDate/releases/tag/5.0.0 maybe you will find their first version for Swift 4.2+ changes usefull. They describe what’s changed from previous versions. Anyway, if you don’t have any specific reasons, I would suggest you to update your Xcode to version which supports Swift 4.2+ (means Xcode 10+) – Robert Dresler Jan 14 '19 at 18:21
  • Yeah I would love to update to XCode 4.2 but unfortunately I am writing my app on a school laptop running High Sierra 10.13.5, and XCode 10+ requires High Sierra 10.13.6... They will most certainly not update my Os so I am stuck with XCode 9.4 til next year I guess. Thanks for all the help though :) (also I figured out that `regionNY` was an example variable, not a class. My bad.) – Nolan Gelinas Jan 14 '19 at 18:27
  • @NolanGelinas ok, so is everything alright now? I’m glad! Good luck mate! ;) – Robert Dresler Jan 14 '19 at 18:30