I've been following the part 1 tutorial until the point where they deploy the widgets to the simulator.
I noticed that my widget was completely blank.
Checked other widgets and noticed that the apple news widgets on the simulator is like this as well.
Heres the code:
I noticed that my widget was completely blank.
Checked other widgets and noticed that the apple news widgets on the simulator is like this as well.
Heres the code:
Code Block Swift // // EmojiRangerWidget.swift // EmojiRangerWidget // // Created by Brent Mifsud on 2020-06-24. // Copyright © 2020 Apple. All rights reserved. // import WidgetKit import SwiftUI import Intents struct Provider: IntentTimelineProvider { public func snapshot(for configuration: ConfigurationIntent, with context: Context, completion: @escaping (SimpleEntry) -> ()) { let entry = SimpleEntry(date: Date(), character: .panda) completion(entry) } public func timeline(for configuration: ConfigurationIntent, with context: Context, completion: @escaping (Timeline<Entry>) -> ()) { var entries: [SimpleEntry] = [ SimpleEntry(date: Date(), character: .panda) ] // Generate a timeline consisting of five entries an hour apart, starting from the current date. let currentDate = Date() for hourOffset in 0 ..< 5 { let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! let entry = SimpleEntry(date: entryDate, character: .panda) entries.append(entry) } let timeline = Timeline(entries: entries, policy: .atEnd) completion(timeline) } } struct SimpleEntry: TimelineEntry { public let date: Date let character: CharacterDetail } struct PlaceholderView : View { var body: some View { Text("Placeholder View") } } struct EmojiRangerWidgetEntryView : View { var entry: Provider.Entry var body: some View { AvatarView(entry.character) } } @main struct EmojiRangerWidget: Widget { private let kind: String = "EmojiRangerWidget" public var body: some WidgetConfiguration { IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider(), placeholder: PlaceholderView()) { entry in EmojiRangerWidgetEntryView(entry: entry) } .configurationDisplayName("Emoji Ranger Detail") .description("Keep track of your favorite emoji ranger.") } } struct EmojiRangerWidget_Previews: PreviewProvider { static var previews: some View { AvatarView(.panda) .previewContext(WidgetPreviewContext(family: .systemSmall)) } }