8

How can I add complications to my EXISTING Xcode 7 project?

Looking at WWDC video 2015 session 209 the way shown to add complications is to create a new project and click on Include Complication. This works fine for that case but how can I add them in an existing project?

enter image description here

I can't find a complication controller in the XCode object selector (See below):

enter image description here

Why is this happening??

lewis
  • 2,531
  • 2
  • 32
  • 56
mm24
  • 8,150
  • 11
  • 65
  • 159
  • 4
    Having used Xcode for 4 years now, trust me, Xcode already comes equipped with a never-ending list of complications as standard. – Mike Gledhill Aug 21 '15 at 12:10
  • Ah ah... thanks Mike :-), I realised that too in my four years of XCode experience.. and every year they change things – mm24 Aug 21 '15 at 12:14

2 Answers2

7

Add a new temp watch extension target and check the complication check box. Copy the complication extension properties from this new info.plist (CLKComplicationSupportedFamilies, WKExtensionDelegateClassName & CLKComplicationPrincipalClass) into your old watch extension info.plist. Once you do that you will see the complication Families listing.

I also moved the ExtensionDelegate & ComplicationController classes into the old watch extension and changed the target membership to the old watch extension from the new watch extension.

Right click inside the old watch extension asset file and add the complication image set.

Also "tom_witkin Jul 23, 2015 8:50 AM (in response to breville) The ClockKit framework is only available on watchOS 2, not iOS. Thus, complications are not supported for existing WatchKit apps where the extension is running on the iPhone."

So do the recommended build settings change when moving from wos1 to wos2 (if there is a warning during compilation), and make WATCHOS_DEPLOYMENT_TARGET = 2.0 in both the old extension & watch app build settings.

Add TARGETED_DEVICE_FAMILY = 4 for old watch extension, if not present.

Gamma-Point
  • 1,444
  • 13
  • 14
2

There is no such thing like a complication controller in Interface Builder it is an abstract entity. You should use ClockKit Framework to register timeline entries and only after that these entries will be available through supported complications on Watch faces.

You can configure supported complication types on your Watch Extension target configuration tab - just check necessary checkboxes. And there is a trick you should specify a name of your complication controller using the next scheme: $(PRODUCT_MODULE_NAME).YourComplicationControllerName

Dmytro Hutsuliak
  • 1,677
  • 4
  • 19
  • 34
  • 1
    Hello, unfortunately there are no such checkboxes in a project that was created in Xcode 6 and imported in Xcode 7. Hence my question: "how to add them to an existing project". I should have specified an "imported project". – mm24 Sep 07 '15 at 13:11
  • Hmm... strange because my project has existed since Xcode 6 as well and I have these checkboxes. Are you sure you check your Watch Extension target settings? Here's how they look at my project: http://imgur.com/ZvUzoZC – Dmytro Hutsuliak Sep 07 '15 at 13:39
  • I have noticed that you gotta do this when your code is in swift, if it's objective-c the name of the class by itself works – Mona Nov 28 '20 at 07:54