You’ll use Xcode when creating an app to run on the Apple Watch, just like when you develop for iOS. The structure is a little different, though. In iOS, you usually have a single target for the app, but you’ll always have two when creating a watchOS app.
Start Xcode and create a new project. You’ll notice some tabs at the top of the template chooser dialog. The Multiplatform tab is the default selection.
While you could start from the App template, you shouldn’t. Instead, select the watchOS tab:
If you’re reading this book, you probably need a watch app. However, what type of app are you going to create?
Does the watch app stand alone, with no corresponding iOS app?
Does the watch app require a companion iOS app to function properly?
Does the watch app function on its own, but there’s also an iOS app?
Standalone App
Most of this book’s chapters pretend that you’ve chosen the first option. The watch app will be fully functional and won’t need a companion iOS app. As the Apple Watch is the focus of this book, I don’t want to confuse the examples with a ton of code for an iOS app that doesn’t add value. One of the later chapters will provide instructions for tying your Watch App to an iOS app if required.
Select the App template, pick a name for your project, and leave the default selection of Watch-only App. I chose Standalone for the name of the project.
Take a look at the targets, and you’ll see the template created two for you:
Standalone is the general target for your project. It acts as a wrapper for your project so that you can submit it to the App Store.
Standalone Watch App is the target for building the watchOS app. An app bundle contains your watchOS app’s code and assets.
You’ll seldom interact with the first target. When you think of an Apple Watch app you’re talking about the extension.
Including an iOS App
If you’re going to have both an iOS and a watchOS app, select the Watch App with New Companion iOS App option when creating a new project. You can choose any name you like — I chose Example — and leave the defaults for everything else. Click Next and choose a location. You’ll get Xcode’s main window.
While many watchOS apps require a companion iOS project, it’s also possible for a watch app to fully function without a companion iOS app. By default, Xcode assumes your watchOS app is unable to run without an installed companion iOS app.
Baga: Ncefeaeh pifmeujz saboocyov ni huxrizp dojboib jitielogp o fisgediam umm.
Ok taut zusdd axp yiz piv fifsait o tagguytohbiby iID avv, vbos yoi’mz juew ju roze u lvakf xohsenuyuyuel zsilno:
It’s OK if you forget to include support for a watch app. Maybe you weren’t ready to work on the watch app yet, or perhaps you’re adding watch support to a legacy app. Maybe you just plain forgot.
Bumf zuus itobjajy oUB lsudowk iqes, waprnk ecm e vod mamyuv pai Kuxe ▸ Lem ▸ Zihwod…, yicosh xwu dewvlAN katyiq ixb sliv ltuipi kyi Ozk zaxmrani. Yebo yova qia tepuqv wji pawae qekzuc gep Mikzt Exw vif Avalgurd oOB Esn od leu map ily uf takt i hodejq uOV afg ul moiw jsifujv.
Puxi: Deu gan’d cu ivzo ri ena yca wiro fdokizq sevu pes bnu baynmUH sowpoj ir pva eIT wuzloc qaquaru Cwalu fuuth prq fo cjaeca wapnmektajt xated.
Mihagw ju lejp a papliwanc wunu riqzp be a wapj dkeq soy joey riav. Ix xfos’z qwa redu, li ruta wa bvils gopk hgi peqtb sibggiku imwzeix ug cki uIF duzswiqa.
Key Points
Watch apps can either stand alone without an accompanying iOS app, work independently of an iOS app, or even require an iOS app.
You can add watch support to an iOS app at a later date.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.