PLEASE - how do you structure an app with Widgets and Complications?

Current project structure:

  • Main iOS app (targets iOS 17).
  • Widget Extension (targets iOS 17).
  • Watch app (targets watchOS 10).
  • Complications Extension (a Widget Extension, targets watchOS 10).

I did have the complications embedded within the Watch app, but you cannot have two @mains in the same target so the complications are in their own WidgetKit extension.

Sadly, when you add a WidgetKit extension to your project, Xcode ALWAYS sets it as an iOS widget extension; it doesn't give you the choice to make it a watchOS extension so you have to figure it out yourself.

Now, I'm hitting an issue where the main iOS app works fine, the iOS widgets work fine, the Watch app runs fine, but the complications dot show up anywhere. I can't preview them in Xcode because it says various things like:

This app was not built to support this device family; app is compatible with (
1,2
) but this device supports (
4
}

I can't find any information on what goes where in the build settings.

Can someone tell me how each bit of the project should look in the build settings, please?

(There's no information anywhere in Apple's developer documentation - which is a bit weird. They've released Xcode and they have no information on the various bits. And why doesn't Xcode set up a WidgetKit extension properly when you add it? Must we all do this manually, Apple?)

Accepted Reply

It's really difficult to tell from this description what exactly is going on in this project, and thus what's gone wrong. I'm not seeing Xcode ALWAYS set a Widget Extension to be an iOS Widget Extension. Where/how are you adding it to your project? I'm doing the following and seeing the widgets provided in the template show up in Previews:

If you are doing the same—adding a watchOS WidgetExtension to your project—and still having trouble, consider contacting Developer Technical Support for some 1:1 help (you can do this from your Developer account).

Replies

It's really difficult to tell from this description what exactly is going on in this project, and thus what's gone wrong. I'm not seeing Xcode ALWAYS set a Widget Extension to be an iOS Widget Extension. Where/how are you adding it to your project? I'm doing the following and seeing the widgets provided in the template show up in Previews:

If you are doing the same—adding a watchOS WidgetExtension to your project—and still having trouble, consider contacting Developer Technical Support for some 1:1 help (you can do this from your Developer account).

Morning. Thanks for the help. It kind of spurred me on to spend a few hours doing this:

  1. Tried adding a new watchOS Widget Extension to hold the complications. Xcode did not offer to embed it in my Watch app (which should've been a red flag, to be honest). This was definitely a watchOS extension. So, that didn't work out.
  2. Cleaned build folder of original app. Tried again. No dice.
  3. Edited the project file and removed any references to files that aren't there anymore (why does this file contain references to deleted files anyway?). Same issue with adding a watchOS Widget Extension.
  4. Tried a new project. Added a Watch app. Added a watchOS Widget Extension. Again, Xcode did not offer to embed it in the Watch app, so again it didn't work.
  5. Took the nuclear option. Deleted Xcode. Deleted any settings for it (plist files etc.). Downloaded it again. Installed. Added watchOS extension to my original app, and this time it did offer to embed it.

I've no idea why my install was borked, but I'm now seeing previews. Thanks for the response.