34

I'm trying to create an iOS WatchOS5 complication and am seeing a number of tutorials and apple documentation. They talk about:

  • WatchKit App
  • WatchKit App extension

What is the difference between iOS WatchKit App and WatchKit App Extension?

If I want to share data between my phone app and my watch app, do I need both in order to use Watch Connectivity framework?

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Alex Stone
  • 46,408
  • 55
  • 231
  • 407

1 Answers1

42

Current answer (valid from Xcode 14): the separate 2 targets don't exist anymore, the new default watchOS app template combines the WatchKit App and WatchKit App Extension targets into a single Watch App target, which can store both code and resources, similar to iOS app targets.

See the Xcode 14 release notes (relevant excerpt below).

Xcode 14 includes a new default template for watchOS apps that combines the WatchKit App and WatchKit App Extension targets into a single Watch App target, simplifying code, asset, and localization management. You can deploy single-target watchOS apps to watchOS 7 and later. (83222217)


Historical answer (valid up until Xcode 13): The two come hand-in-hand, both are needed to create a watchOS application and you cannot use one without the other.

The main difference is that a WatchKit App is responsible for displaying the UI, so this is where you store the storyboard(s) and all assets (images, etc) used from storyboards. On the other hand, your WatchKit App Extension is responsible for everything done programatically, so this is where all your interface controllers and other classes should reside. You should also store all assets that you access from code in your App Extension target.

You'll need to use the WatchConnectivity framework from code as part of your App Extension target, however, as already stated, all watchOS applications need to have a WatchKit App target as well.

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • I've created new project and all things are in Extension package, in app there is Assets directory and Info.plist. Is it right? – Marek Kondracki Jan 30 '20 at 09:06
  • 2
    @MarekKondracki if you using SwiftUI, that's right, if you are using storyboards, those should go into the app. – Dávid Pásztor Feb 03 '20 at 09:54
  • Thanks for the answer. Do you have any information on the reason why there are two targets? Both of them run on the watch, don't they? – Jonas Sourlier Nov 17 '21 at 10:22
  • 2
    @cheesus most probably for historical reasons, since back on watchOS 1, watch apps were not able to execute much logic, pretty much all data had to be sent from the connected iOS app ready to be displayed on the watch. And yes, both targets are executed on the watch. – Dávid Pásztor Nov 17 '21 at 10:34
  • 1
    It seems like creating a new watch app project (with companion app) nowadays (Xcode 14 beta 5) does *not* include an extension anymore. – Martin Aug 17 '22 at 10:39
  • 2
    @Martin thanks for pointing that out, indeed Xcode14 introduced a new watchOS app template, I've updated my answer to reflect this change – Dávid Pásztor Aug 17 '22 at 10:49