How to run a WatchKit App

こ雲淡風輕ζ 提交于 2019-11-29 13:51:26

When you run, did you change the scheme to the WatchKit App target? Or did you just build & run the iOS app as usual? For now you can't run both the iOS app target and Watch App target at the same time.

You have to switch schemes/targets as shown here, then pick the same simulator & display the watch UI as you've already done, (in the simulator -> "Hardware" tab -> External Display -> Apple Watch):

You also have to add/edit schemes to view the Glance or Notification parts of the storyboard. See the "Readme" file in the sample Lister project for more details.

I had a similar issue. Here is a couple of things you can try (solved it for me)

  • make sure you app, watchkitapp and watchkitextension have the same bundle id e.g. com.company.app for the app and com.company.app.watchapp for the watchkit app. I have several build configs with different bundle ids, so xcode took the wrong one during watch target creation. You'll get a compiler error if app's and extension's are different, but watchapp bundle id will not create an error.
  • first run of the app, before you open the watch in the external devices menu will hit all the breakpoints and logs but you'll see nothing after you open the watch simulator.
  • a couple of times the app got stuck on launch for me - in debug navigator the state was 'waiting to attach'. had to reset the simulator every time after that.

Hope it helps.

This might not be your problem, but it was mine.

If you include a table in your watch app, you need to implement the methods in the InterfaceController in order for anything to show up. You cannot just put a table in, and then put a label in the first row, and then have it show up (like you would with a static UITableViewController).

Follow this guide for adding tables: https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/Tables.html#//apple_ref/doc/uid/TP40014969-CH14-SW1

Oh man. This one really stumped me. I was working on something in Beta 1 and had a table row which was a subclass of WKInterfaceController. In Beta 5 all I saw was the same blank table view and when calling

[self.interfaceTable rowControllerAtIndex:x]

it was returning nil.

Solution: Switched my row to be a subclass of NSObject and it worked fine!

Just change the scheme to AppName WatchKit App and build.

Kalai_Human
  1. Change the scheme by Go to product -> scheme -> (choose watchkit app target scheme).
  2. Then, Go to product -> scheme -> Edit Scheme and select Run
  3. Change Executable to watchkit App
  4. Build and run the code.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!