Swift ViewController 中的错误 "Use of undeclared type"

Swift error "Use of undeclared type" in ViewController

我正在 Xcode 上使用 ResearchKit 和 Swift 开发一个应用程序。 ResearchKit 软件相对简单,但视图控制器中的这段代码有消息:

"Use of undeclared type"

所有三种 ORKTaskViewControllerXXX 类型,我不确定如何修复它。这是我的代码:

import UIKit

class ViewController: UIViewController {
    @IBAction func consentTapped(sender : AnyObject) {
        let ORKTaskViewController = taskViewController(task: consentTapped, taskRunUUID: nil)
        taskViewController.delegate = self
        presentViewController(taskViewController, animated: true, completion: nil)
    }
}

extension ViewController : ORKTaskViewControllerDelegate {
    func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
        //Handle results with taskViewController.result
        taskViewController.dismissViewControllerAnimated(true, completion: nil)
    }
}

尝试在您调用的视图控制器中添加 import ResearchKit ResearchKit 相关内容。

import UIKit
import ResearchKit