1

I have added CalendarKit in my project using swift package Manager, I tried with cocoapods as well but still I am getting the below errors:
I have added import CalendarKit as well.
1) Value of type 'Date' has no member 'format'

let timezone = TimeZone.ReferenceType.default
        var info:[String] = ["Booking Id: \(bookingDetails.bookingID ?? -1)", "Booking Type: \(bookingDetails.bookingType!)"]
        info.append("Booking From : \(begining.format(with: "dd.MM.YYYY", timeZone: timezone)) \nBooking To : \(ending.format(with: "dd.MM.YYYY", timeZone: timezone))")
        info.append("Timing: \(begining.format(with: "HH:mm")) - \(ending.format(with: "HH:mm"))")
        info.append("Status: \(status)\n")   

2) Value of type 'Date' has no member 'hours'

 if indexPath.section == 1 {
                    selectedbookingRecord = self.upcomingBookings![indexPath.row] as BookingInfoList
                    if let bookingStartDateTime = selectedbookingRecord?.bookingFrom {
                        if (bookingStartDateTime.toDate()?.hours(from: Date()))! < 24 {
                            DispatchQueue.main.async {
                                Alert().showAlert(ALERT_TITLE, message: GlobalConstants.CANNOT_DELETE_BOOKING, okButtonTitle: ALERT_OK_TITLE, CompletionHandler: nil, View: self)
                            }
                            return
                        }
                    }
                }

Thanks in advance!

Mihir Oza
  • 2,768
  • 3
  • 35
  • 61
  • 1
    Apart from your issue `YYYY` is wrong. – vadian Feb 10 '21 at 08:09
  • ok so what should I use instead of YYYY? – Mihir Oza Feb 10 '21 at 08:11
  • Lowercase `yyyy`. Please see https://stackoverflow.com/questions/15133549/difference-between-yyyy-and-yyyy-in-nsdateformatter – vadian Feb 10 '21 at 08:13
  • That's from the ReadMe, but I don't find in their github the extension on `Date` nor the method (on another object) `format(with: String)`. That ReadMe is misleading, or maybe outdated (did that exist beforehand)? And I don't know where you took `hours(from:` from? It's not in their github. – Larme Feb 10 '21 at 08:19
  • 1
    Ok. After some digging. It had previously a dependency on DateSwiftTools which had `func format(with dateFormat: String) -> String` https://github.com/MatthewYork/DateTools/blob/83342e09297a33558d64ea696c3a5e0aae5a8f2a/DateToolsSwift/DateTools/Date%2BFormat.swift#L140 (same for `hours(from:) in Date+Comparators.swift)`. The ReadMe is not up to date at all. – Larme Feb 10 '21 at 08:30
  • Yes @Larme even I can't see those functions, I have 2 years old source code that's why I tagged calendarkit so may be the author can help about this issue. But It works fine on the developer's system who developed. Do you think something I need to add in Build Phase ->run script? – Mihir Oza Feb 10 '21 at 08:32
  • 1
    I did some digging and found out where they were implemented. But they are only in the ReadMe, so I think that's just an outdated ReadMe, shouldn't affect the real code. If you still need the methods, I pointed out the other GitHub needed `DateSwiftTools`. – Larme Feb 10 '21 at 08:34
  • @Larme ok, So did you find any replacement functions for format and hours? – Mihir Oza Feb 10 '21 at 08:34
  • Use the other github. It has a podspec too. If you had that into you real code (and not only in a ReadMe), you should keep the old version of CalendarKit. Else, you might have stronger answers on their GitHub issue. – Larme Feb 10 '21 at 08:36
  • Is it possible to get that version of podspec which has those methods? – Mihir Oza Feb 10 '21 at 08:38
  • 1
    It has been removed there https://github.com/richardtop/CalendarKit/commit/3388a3130f32134eb9cb702ec602fb51ceb48e0e#diff-1d0ac5640b81b88873b83c776bd276c6813adfbd3f6ff49515bc0d36ff87494e use a version corresponding just before – Larme Feb 10 '21 at 10:05

1 Answers1

1

It looks like the provided code has been developed with the older version of CalendarKit which had a dependency on DateToolsSwift. Now, when the dependency has been removed, the code you've provided doesn't compile.

In order to resolve your issue, either use an older version of CalendarKit (not greater than 0.14.0, e.g. 0.13.14 would do just fine),

or, just install and import DateTools independently to the files where you're using that framework.

Richard Topchii
  • 7,075
  • 8
  • 48
  • 115
  • Hello @richard I am getting below error while trying this version: [!] Unable to find a specification for `CalendarKit~> 0.13.14` You have either: * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`. * mistyped the name or version. * not added the source repo that hosts the Podspec to your Podfile. – Mihir Oza Feb 15 '21 at 06:23
  • 1
    Installing DateTools is a better approach, since you'll get all of the newest updates of CalendarKit. I also suggest "fixing" the version of the library used to `0.14.x` if the project is only in maintenance. – Richard Topchii Feb 15 '21 at 16:33