I am working on a new standalone Apple Watch app. However, I am unable to see my widget in the Smart Stack. My goal is to have a singular complication for the .accessoryRectangular
family.
The latest beta I tried is Xcode Beta 8. I can't see the widget either on the Simulator or real hardware.
I have done these steps.
- Added Watch App target with DT set to 10.0. Bundle ID
.watchkitapp
- Added widget extension target with DT set to watchOS 10. Bundle ID
.watchkitapp.widget
- Added
AppIntentTimelineProvider
for thewidgetExtension
target, all based on the example code Backyard Birds: Building an app with SwiftData and widgets - Added the
Widget
to the same target
@main
struct widget: Widget {
let kind: String = "widget"
var body: some WidgetConfiguration {
AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in
widgetEntryView(entry: entry)
}
}
}
struct widgetEntryView : View {
@Environment(\.widgetFamily) private var family
var entry: Provider.Entry
var body: some View {
switch family {
case .accessoryRectangular:
RectangularView(entry: entry)
default:
Text("Not Supported")
}
}
}
What am I missing? In the past I would add the complications controller for the WatchKit
, but I was hoping we don't need to do it.
I will research more into complications and WidgetKit for watchOS 10 and will keep this updated for people who struggling like me.
I can see my widget now. I have not realised that I still have to provide bundle IDs for both targets. This wasn't obvious as during the creation of the project you already provided a bundle identifier. I have kept the default suffixes (1 and 2) and prepended the ID.
File `*.xcodeproj/project.pbxproj`
Key 1 `PRODUCT_BUNDLE_IDENTIFIER`
Key 2 `INFOPLIST_KEY_WKCompanionAppBundleIdentifier`