iosswiftresearchkit

Swift error "Use of undeclared type" in ViewController


I'm working on an app using ResearchKit with Swift on Xcode. The ResearchKit software is relatively straightforward, but this particular section of code in view controller has the message:

"Use of undeclared type"

for all three ORKTaskViewControllerXXX types and I'm not sure how to fix it. Here is my code:

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)
    }
}

Solution

  • Try to add import ResearchKit in the view controller you are calling the ResearchKit related stuff.

    import UIKit
    import ResearchKit