无法连接来自第三方库的代码

Unable to connect code from a third-party library

我尝试连接这个库,但是这个错误落在了代码中。我在论坛上没有找到答案,我做错了什么?

https://github.com/miraan/CalendarDateRangePickerViewController

https://yadi.sk/d/Cze6fOwcrV01tA

let dateRangePickerViewController = 
CalendarDateRangePickerViewController(collectionViewLayout: 
UICollectionViewFlowLayout())
dateRangePickerViewController.delegate = self
let navigationController = UINavigationController(rootViewController: 
dateRangePickerViewController)
self.navigationController?.present(navigationController, animated: true, 
completion: nil)

CalendarDateRangePickerViewController 2 年未更新,因此您需要进行一些更改才能使用该库。

这里我用Xcode 10.1实现了它,按照下面的步骤使用它。

首先将 pod 添加到您的 pod 文件中。

pod 'CalendarDateRangePickerViewController'

然后使用pod install命令。

然后 select 来自 Targets 的广告连播。检查下图。

然后在第 3 步中搜索 Swift Language Version 和 select Swift 3

然后去你的 class 你想要用户这个库的地方

并添加

import CalendarDateRangePickerViewController

现在您的第三方库可以使用了,您可以添加示例代码,如下所示:

import UIKit
import CalendarDateRangePickerViewController

class ViewController: UIViewController, CalendarDateRangePickerViewControllerDelegate {

    func didTapCancel() {

    }

    func didTapDoneWithDateRange(startDate: Date!, endDate: Date!) {

    }


    override func viewDidLoad() {
        super.viewDidLoad()
        let dateRangePickerViewController =
            CalendarDateRangePickerViewController(collectionViewLayout:
                UICollectionViewFlowLayout())
        dateRangePickerViewController.delegate = self
        let navigationController = UINavigationController(rootViewController:
            dateRangePickerViewController)
        self.navigationController?.present(navigationController, animated: true,
                                           completion: nil)
    }
}

HERE 是更多信息的示例项目。

编辑:

但是每当您在终端中点击 pod installpod update 命令时,您需要再次将 Swift Language Version 设置为 Swift 3