xcodewidgetwatchos

Xcode Widget Extension Cannot Preview in WatchOS


I am adding a Widget Extension (named Complication) to my WatchOS app. When creating the widget, I am not able to select an application in the field "Embed in Application". The app name shows up, but I can only select "None".

When I want to preview the widget, the following error message comes up:

AppExtensionNeedsContainingAppError: ComplicationExtension.appex must be in an app

The app extension "ComplicationExtension.appex" needs to be embedded in an app in order to use previews

What can I do to get it to work? I added the app in the Target Membership but that does not work. What am I missing?


Solution

  • You will need to follow the answer here: https://stackoverflow.com/a/76467859/1203713

    1. Add the watchOS Widget Extension
    2. Make sure the extension is embedded in the watchOS App and not in the WatchKit Extension
    3. Make sure the bundle identifier does not contain .watchkitapp.watchkitextension

    Then it worked fine for me