Reputation: 23
I am trying to use @WidgetBundleBuilder to create multiple widgets, but the problem is that even though they are linked to two different views it makes both of the widgets have the same views. The code looks like this.
struct MountainWeatherWidgetCard: Widget {
let kind: String = "MountainWeatherWidget"
var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: ProviderTC()) { entry in
MountainWeatherWidgetEntryViewCardrona(entry: entry)
}
.configurationDisplayName("Mountain Weather")
.description("Get a quick overview of current weather at one ski field")
.supportedFamilies([.systemSmall])
}
}
struct MountainWeatherWidgetTC: Widget {
let kind: String = "MountainWeatherWidget"
var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: ProviderTC()) { entry in
MountainWeatherWidgetEntryViewTC(entry: entry)
}
.configurationDisplayName("Mountain Weather")
.description("Get a quick overview of current")
}
}
@main
struct WeatherWidgets: WidgetBundle {
@WidgetBundleBuilder
var body: some Widget {
MountainWeatherWidgetTC()
MountainWeatherWidgetCard()
}
}
When I run this code there will be 4 widgets, 1 small widget from MountainWeatherWidgetCard and the other 3 from MountainWeatherWidgetTC, that appear but they will all have the same view. How would I stop this from happening?
Upvotes: 1
Views: 632
Reputation: 5145
Both of your widgets have the same kind:String = "MountainWeatherWidget". This needs to be a unique string for each type of widget.
Upvotes: 3