Search code examples
watchosapple-watch-complication

Cannot add a complication to an existing watchOS project


I have an existing watchOS app. It's deployment target is 6.1.

I added a new widget extension by going to File -> New -> Target -> Widget Extension.

I did NOT check the "Include Configuration Intent".

In the "Embed in" drop down I chose the WatchKit Extension (it was the only one available).

I did not change any of the generated code, other than to add @available(watchOS 9.0, *) to the structs.

I attempted to preview the widget in the preview canvas but I got the following error:

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

I then checked the "MyProject WatchKit Extension" under the Target Membership in the File Inspector. The Preview Canvas then crashed with the following error:

Couldn't retrieve XPCService dictionary from service bundle.
----------------------------------------

CrashReportError: MyProject WatchKit Extension crashed

MyProject WatchKit Extension crashed. Check ~/Library/Logs/DiagnosticReports for crash logs from your application.

Process: MyProject WatchKit Extension[7194]

Date/Time: 2023-02-25 01:10:25 +0000

Log File: <none>

Application Specific Information:

    libxpc.dylib [

        Configuration error: Couldn't retrieve XPCService dictionary from service bundle.

    ]

    libsystem_sim_platform.dylib [
CoreSimulator 857.14 - Device: Apple Watch Series 8 (45mm) (9D9982CB-5C86-4A90-913E-44C50CD846B1) - Runtime: watchOS 9.0 (20R362) - DeviceType: Apple Watch Series 8 (45mm)
]

<snipped rest of crash report>

I don't know what to try from here. Any ideas appreciated.

Thank you!


Solution

  • I was not able to get the complication to display in the Preview Canvas. However, it does work in the simulator and on the device. I ran the project and was able to add the complication to the watch face.

    Note: In my question I stated: "I then checked the "MyProject WatchKit Extension" under the Target Membership in the File Inspector." This step is wrong, and I undid this action.