Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is WKInterfacePicker considered an undeclared type?

I'm using Xcode Version 7.0 beta 3. When attempting to use a WKInterfacePicker, I get an error.

Here is my code for my WKInterfaceController:

import WatchKit
import Foundation


class RBWelcomeVC: WKInterfaceController {

@IBOutlet var pickerAllWorkouts: WKInterfacePicker!


override func awakeWithContext(context: AnyObject?) {
    super.awakeWithContext(context)

    // Configure interface objects here.
}

override func willActivate() {
    // This method is called when watch view controller is about to be visible to user
    super.willActivate()
}

override func didDeactivate() {
    // This method is called when watch view controller is no longer visible
    super.didDeactivate()
}

}

Notice my IBOutlet. When I created it by Control dragging from the storyboard. It created the outlet and immediately put this error with it:

 Use of undeclared type 'WKInterfacePicker'

Since that didn't work, I tried creating the outlet manually. I typed:

 @IBOutlet var pickerAllWorkouts: WKInterfa...

When attempting to let Xcode finish the autocomplete, I noticed that WKInterfacePicker was not a suggestion. The picker did not exist. Is this just a bug or am I doing something wrong?

like image 218
iOSAppGuy Avatar asked Mar 15 '23 11:03

iOSAppGuy


1 Answers

You should check that the "Target Membership" of the RBWelcomeVC.swift file is not included in your iOS app, it only should be on your Apple Watch Extension. That worked for me.

"Target Membership" is located in the side bar of Xcode (AKA: Utilities)

Need more reputation to post image.

EDIT: image: http://imgur.com/rQ1xwtG

like image 101
Fernando Romiti Avatar answered Mar 23 '23 13:03

Fernando Romiti