-1

There is no complication compiled on my Apple Watch.

  1. I simply duplicated target for my iOS widget to extend it to watchOS.
  2. I have changed Targetet Device Families to Apple Watch
  3. I have changed Base SDK to watchOS
  4. i have changed bundle identifier and provisionings
  5. I have embedded complication target to my watch app target.

Everything is compiled correctly. No issues, warning, errors. But when I try to add complication to my watch face, it doesn't exist on the list. Why?

Am I missing something?

This is my Widget code:

import WidgetKit
import SwiftUI

struct CurrentMonth: Widget {
    @available(watchOS 9.0, *)
    var families: [WidgetFamily] {
#if os(watchOS)
        return [.accessoryInline, .accessoryCircular, .accessoryRectangular]
#else
        if #available(iOS 16.0, *) {
            return [.systemSmall, .systemMedium, .systemLarge, .systemExtraLarge, .accessoryInline, .accessoryCircular, .accessoryRectangular]
        } else {
            return [.systemSmall, .systemMedium, .systemLarge, .systemExtraLarge]
        }
#endif
    }
    @available(watchOS 9.0, *)
    var body: some WidgetConfiguration {
        StaticConfiguration(
            kind: "WidgetCurrentMonth",
            provider: MonthTimeline(), content: { entry in
                WidgetCurrentMonthView(entry: entry)
            })
            .configurationDisplayName("widget.currentmonth.title".localized)
            .description("widget.currentmonth.description".localized)
            .supportedFamilies(families)
    }
}

@available(watchOS 9.0, *)
struct WidgetCurrentMonthView: View {
    let entry: LastMonthEntry
    @Environment(\.widgetFamily) var family
    var body: some View {
        HStack {
            Image.briefcase
            Text("abcd")
        }
    }
}

Code is shared for both: my iOS widget target and my watchOS complication target.

Additionally:

I have downloaded example project from Apple:

https://developer.apple.com/documentation/widgetkit/adding_widgets_to_the_lock_screen_and_watch_faces

and tried to install it on watch simulator and on watch device and it also doesn't work. Why?

Watch face I am trying to use:

enter image description here enter image description here enter image description here

My App is called Field Service Watch so should be between Compass and Heart Rate

halfer
  • 19,824
  • 17
  • 99
  • 186
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358

1 Answers1

0

A few things to check:

  1. Check if your complication is properly configured in your watch app target's Info.plist file. Specifically, ensure that the complication types and supported families are properly specified.
  2. Verify that your complication target is included in the "Embed Watch Content" build phase of your watch app target.
  3. Check if your complication bundle identifier is properly formatted. It should be in the format of "com.company.app.watchkitapp.watchkitextension.complication".

However, given that the demo project does not work for you either, I'm thinking you should double check the watch face you are attempting to use the complication with. Verify that you have selected a watch face that is compatible with your complication (and the demo complication). Some watch faces only support certain complication types and families.

Do you have an image or recording? Does it work on a sim?

TJ Olsen
  • 323
  • 2
  • 15
  • Hello, thank you for your answer. 1. Do I have to define complication types and supported families in info.plist? 2. Yes, it is included. 3. It is correctly defined. What face did I select? Is not enough to use watch face where for example rectangular complication is in use? – Bartłomiej Semańczyk Apr 19 '23 at 16:37
  • I have added watch face to the question. – Bartłomiej Semańczyk Apr 19 '23 at 18:13