类型 'Date' 的值没有成员 'format' & 类型 'Date' 的值没有成员 'hours'

Value of type 'Date' has no member 'format' & Value of type 'Date' has no member 'hours'

我已经使用 swift 包管理器在我的项目中添加了 CalendarKit,我也尝试使用 cocoapods,但仍然出现以下错误:
我也添加了import CalendarKit
1) 'Date' 类型的值没有成员 '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) 'Date' 类型的值没有成员 '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
                        }
                    }
                }

提前致谢!

看起来所提供的代码是用 CalendarKit 的旧版本开发的,它依赖于 DateToolsSwift。现在,删除依赖项后,您提供的代码无法编译。

为了解决您的问题,请使用旧版本的 CalendarKit(不大于 0.14.0,例如 0.13.14 就可以),

或者,只需安装并导入 DateTools 独立到您使用该框架的文件。