imgg
imgg

Reputation: 468

WidgetKit .supportedFamilies Complications only available for iOS 16.0 or newer

Within a non-iOS 16 target project when I tried to do

IntentConfigIntentConfiguration(
    kind: kind,
    intent: SelectIntent.self,
    provider: WidgetProvider()
) { entry in
    WidgetEntry(entry: entry)
}
    .configurationDisplayName("Display Name")
    .description("Description")
    .supportedFamilies([.systemSmall, .systemMedium, .accessoryInline])

I got

'accessoryInline' is only available in application extensions for iOS 16.0 or newer

on .supportedFamilies([.systemSmall, .systemMedium, .accessoryInline])

Is there any good ways that I could work around this, so that users with < iOS 16.0 could still use the .systemSmall and .systemMedium widgets, while the users on >= iOS 16.0 could enjoy the lock screen complications?

Any help would be appreciated!

Upvotes: 0

Views: 1568

Answers (1)

imgg
imgg

Reputation: 468

Found a nice way to use extensions which is inspired by an awesome post :D

extension WidgetConfiguration {
    func adaptedSupportedFamilies() -> some WidgetConfiguration {
        if #available(iOS 16, *) {
            return self.supportedFamilies([
                .systemSmall,
                .systemMedium,
                .accessoryInline
            ])
        } else {
            return self.supportedFamilies([
                .systemSmall,
                .systemMedium
            ])
        }
    }
}

Upvotes: 4

Related Questions