Reputation: 219
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?
Upvotes: 4
Views: 851
Reputation: 2092
The problem is you are using widgetkit(WidgetKit) needs to attach to an application.
Upvotes: 0
Reputation: 2031
You will need to follow the answer here: https://stackoverflow.com/a/76467859/1203713
Then it worked fine for me
Upvotes: 0
Reputation: 51
I was having the same issue first in my project (Watch only app). I figured that after selecting File > New > Target I also had to select WatchOS on the top before clicking "Widget Extension" otherwise I ran into the same problem (by default it added an iOS widget extension). With the right platform selected I was able to choose which app to embed the widget in and the preview worked correctly
Upvotes: 0