I created a widget with WidgetKit, it really works high quality after I run the appliance from Xcode on the simulator, nevertheless it doesn’t discover this widget on an actual system.
Perhaps somebody will inform me why?
I examined on actual gadgets with iOS 15.8.3, 18.1.
I attempted construct on one other actual system, however I bought the identical challenge.
There my code:
import WidgetKit
import SwiftUI
struct Supplier: TimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
SimpleEntry(date: Date(), emoji: "😀")
}
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry(date: Date(), emoji: "😀")
completion(entry)
}
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
var entries: [SimpleEntry] = []
let currentDate = Date()
for hourOffset in 0 ..< 5 {
let entryDate = Calendar.present.date(byAdding: .hour, worth: hourOffset, to: currentDate)!
let entry = SimpleEntry(date: entryDate, emoji: "😀")
entries.append(entry)
}
let timeline = Timeline(entries: entries, coverage: .atEnd)
completion(timeline)
}
}
struct SimpleEntry: TimelineEntry {
let date: Date
let emoji: String
}
struct PanicWidgetEntryView : View {
var entry: Supplier.Entry
var physique: some View {
VStack {
Textual content("Time:")
Textual content(entry.date, type: .time)
Textual content("Emoji:")
Textual content(entry.emoji)
}
}
}
struct PanicWidget: Widget {
let variety: String = "PanicWidget"
var physique: some WidgetConfiguration {
StaticConfiguration(variety: variety, supplier: Supplier()) { entry in
if #obtainable(iOS 17.0, *) {
PanicWidgetEntryView(entry: entry)
.containerBackground(.fill.tertiary, for: .widget)
} else {
PanicWidgetEntryView(entry: entry)
.padding()
.background()
}
}
.configurationDisplayName("My Widget")
.description("That is an instance widget.")
}
}
import WidgetKit
import SwiftUI
@primary
struct PanicWidgetBundle: WidgetBundle {
var physique: some Widget {
PanicWidget()
}
}
Sure, that is the default widget from Apple, nevertheless it additionally solely works on the simulator, however on an actual system the widget is just not discovered.
I attempted all of the guides on creating widgets on the community and the scenario is similar.
Additionally I used Console.app to observe to the related processes associated to my app and extensions and located these logs – Logs right here
I perceive that is the rationale why I am unable to discover my widget within the search? However why is that this so and methods to repair it?
Perhaps somebody can inform me what I am doing unsuitable?
Thanks rather a lot!