4

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?

iOSAppGuy
  • 633
  • 7
  • 23
  • This definitely isn't a bug. I am trying to do the same thing right now and just got the same issue. Did you by any chance get this solved? – sdoowhsoj Jul 16 '15 at 03:08
  • Actually, I think I figured it out...I accidentally added a Watchkit Extension Target instead of a watchOS App Target. I haven't tested this theory out but I noticed that there was an entire section devoted to watchOS when adding a target that is probably why this is undeclared, since WKInterfacePicker wasn't available in WatchKit 1. – sdoowhsoj Jul 16 '15 at 04:53
  • So what do people do that created the extensions for watchOS1? – Ace Green Jul 18 '15 at 14:26

1 Answers1

7

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: https://i.stack.imgur.com/jFCEm.jpg