iosswiftresearchkit

ORKESerializer Researchkit test class giving error while building for iOS device


While working on my first researchkit project, I had a requirement of serializing the results of Researchkit survey into json. I need this json data to send the survey answers back to server. To serialize the ORKResult object it has been advised to use function ORKESerializer.JSONDataForObject(taskResult). This function will convert the custom object into proper valid json object. ORKESerializer is not actually part of Researchkit but it was included in a test app, called ORKTest that is on GitHub. Below is the code that does this.

extension ViewController : ORKTaskViewControllerDelegate {

func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
    switch reason {
    case .Completed:
        let taskResult = taskViewController.result

        let jsonData = try! ORKESerializer.JSONDataForObject(taskResult)
        if let jsonString = NSString(data: jsonData, encoding: NSUTF8StringEncoding) {
            print(jsonString)
        }
        break

    case .Failed, .Discarded, .Saved:
        break

    }
    //Handle results with taskViewController.result
    taskViewController.dismissViewControllerAnimated(true, completion: nil)
}

Now this code is working perfectly fine while running in a simulator. But it is giving an error while trying to build for ios device. I have added ORKESerializer.h and .m files into my swift project and also imported .h in bridging header. Below is the error that it is throwing while compilation.

{ Undefined symbols for architecture armv7: "_OBJC_CLASS_$_ORKLocation", referenced from: objc-class-ref in ORKESerialization.o "_OBJC_CLASS_$_ORKConfirmTextAnswerFormat", referenced from: objc-class-ref in ORKESerialization.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) }

Attached Image for the error

Does any one know how to fix this?


Solution

  • As per this Link this issue has been fixed and merged with stable version in Github.