I had to use a mix of things:
import WidgetKit
import SwiftUI
@main
struct widgetBundle: WidgetBundle {
@WidgetBundleBuilder
private var iOSAllWidgets: some Widget {
LockScreenWidget()
}
@available(iOSApplicationExtension 17.0, iOS 17.0, *)
@WidgetBundleBuilder
private var iOS17Widgets: some Widget {
LockScreenWidget()
LiveActivityWidget()
}
@available(iOSApplicationExtension 18.0, iOS 18.0, *)
@WidgetBundleBuilder
private var iOS18Widgets: some Widget {
LockScreenWidget()
LiveActivityWidget()
LauncherControlWidget()
}
var body: some Widget {
if #available(iOSApplicationExtension 18.0, *) {
return iOS18Widgets
} else {
return getWidgetsThatAreNOTControlWidgets()
}
}
private func getWidgetsThatAreNOTControlWidgets() -> some Widget {
if #available(iOSApplicationExtension 17.0, *) {
return iOS17Widgets
} else {
return iOSAllWidgets
}
}
}
If you add more than one if else block in the body it complains about control flow statements. You can't use WidgetBundleBuilder.buildBlock for control widgets. If you try to use the function alone, it complains that the function does not return the same type for all the return statements because somehow control widget doesn't conform to widget.
This will have to do until we get the fix in Xcode 16.1 beta 3.
Post
Replies
Boosts
Views
Activity
See https://stackoverflow.com/questions/78716058/ios-18-control-widget-that-opens-a-url for suggestions.
I have the same issue with location permission.
I tried adding a Settings bundle, it didn't work for me.
What works for me while doing development, and only as a temporary fix, is to ask for NOTIFICATION permission on app launch and grant the notification permission, even if I don't need it in the app.
My app appears in Settings immediately after granting notification permission.
Not a great workaround but useful for my purposes while developing and testing with location permission.
Logged in Feedback Assistant: FB12645837
Logged in Feedback Assistant: FB12645676
I figured it out.
I didn't have this item checked:
Obivously.... if I'm going to use ".setShortcutSuggestions" the definition should be eligible for it! (Sigh...Common sense failure on my part.)
Leaving this post on here in case someone else has the same issue. The error message was a little confusing.
This is still an issue!!
I received a 'LONG' value for download_id in a receipt. Good thing I found this post, or I would not have been warned that it can be null too!