Post

Replies

Boosts

Views

Activity

Reply to StaticConfiguration.init(kind:provider:placeholder:content:) deprecated warning
ok, I implemented the new (in beta 3) method: placeholder(with: Context). The widget shows up on the device when I run locally, but when distributed using TestFlight, HomeWidget disappears and cannot be added. Here his my code for the TimeLineProvider. What am I missing?     public typealias Entry = SimpleEntry     let dict_dummy = ["Gizmo": ["SOC": 89, "ratedRange": 196, "estimatedRange": 185, "unit": "mi", "isTestUser": true]]     public func snapshot(with context: Context, completion: @escaping (SimpleEntry) -> ()) {         var  dict = defaults?.dictionary(forKey: Constants.WIDGET_DICT)         if dict == nil {             dict = dict_dummy         }         let entry = SimpleEntry(date: Date(), dict: dict)         completion(entry)     }     public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {         let currentDate = Date()         let refreshDate = Calendar.current.date(byAdding: .minute, value: 10, to: currentDate)!         let dict = defaults?.dictionary(forKey: Constants.WIDGET_DICT)         let entry = SimpleEntry(date: Date(), dict: dict)         let timeline = Timeline(entries: [entry], policy: .after(refreshDate))         completion(timeline)     }     func placeholder(with: Context) -> SimpleEntry {         let entry = SimpleEntry(date: Date(), dict: dict_dummy)         return entry     } } @main struct HomeWidget: Widget {     private let kind: String = "HomeWidget"     public var body: some WidgetConfiguration {         StaticConfiguration(kind: kind, provider: Provider()) { entry in             HomeWidgetEntryView(entry: entry)         }         .configurationDisplayName("Stats Widget")         .description("Shows battery SoC and Rated Range")         .supportedFamilies([.systemSmall, .systemMedium])     } }
Jul ’20