Better Programming

Advice for programmers.

Follow publication

Member-only story

Getting Started With watchOS 9 Complications in WidgetKit

Alex Bartiş
Better Programming
Published in
6 min readNov 9, 2022

--

Photo by Alvaro Perez on Unsplash

I had some fun recently adding complications to my strength training app Strength++, as I went directly to the “new” WidgetKit framework. It’s not actually new, but what is new in wOS 9 is that you can use WidgetKit instead of the old ClockKit to create complications for the watch.

Let’s not lose more time and get to work. You will find the code here, both in an initial version if you want to code along and a final version if you want to look over everything.

We’re using a DailyQuote app I’ve created for this purpose, which shares most of its code base between the iOS and watchOS app. iOS app is targeting iOS 16, and watchOS, of course, has a minimum version of wOS 9.

app running both on watch and iPhone simulator
app running both on watch and iPhone simulator

We first need to add an extension for the complications, so in Xcode, go to File -> New -> Target, select the watchOS tab and then select Widget extension.

Xcode New Target watchOS WidgetExtension
Xcode New Target watchOS Widget Extension
  • Tap Next.
  • Insert a product name.

I went for DailyQuote Complications.

  • Uncheck Include Configuration Intent, as these complications we’re building today are not configurable
  • Make sure your project is selected in the dropdown and also Embed in is set to your watch app.
Configure the target

Tap Finish and Activate to activate your new target.

Activate the new target

You can see now in the project navigator that a new folder under the name you provided before contains a swift file, an Assets folder, and an Info.plist file. Go ahead and open the…

--

--

No responses yet

Write a response