Post

Replies

Boosts

Views

Activity

WidgetKit Timeline Updates
I am creating a widget using WidgetKit to display the iPhone battery level. I setup the following timeline to update the widget very minute. (I use one minute for testing the app. Once it works I'll use five minutes to preserve resources.) In the "View" I display the time and battery level. The time is updated every minute. However, the battery level does not get updated. func getTimeline(in context: Context, completion: @escaping (Timeline) -> ()) { var entries: [SimpleEntry] = [] let currentDate = Date() let updateInterval = 1 for minuteOffset in stride(from: 0, to: 60, by: updateInterval ) { let entryDate = Calendar.current.date( byAdding: .minute, value: minuteOffset, to: currentDate )! let entry = SimpleEntry( date: entryDate ) entries.append(entry) } let timeline = Timeline(entries: entries, policy: .atEnd) completion(timeline) } // func var body: some View { let _ = UIDevice.current.isBatteryMonitoringEnabled = true let batteryLevel = UIDevice.current.batteryLevel VStack { Text(entry.date, style: .time) let str = String( format: "%.0f%%", batteryLevel * 100.0 ) Text( str ) } } // some View
2
0
531
Sep ’22
Xcode duplicates home screen widgets
Xcode 14.1, iOS 16.1, MacOS 12.5, Working on a Lock Screen widget with home screen widget. This code: struct Battery_LevelEntryView : View { @Environment(\.widgetFamily) var widgetFamily     var entry: Provider.Entry     var body: some View { switch widgetFamily{ case .systemSmall: ... case ... : If I include the .systemSmall case, each time I run the app on the iPhone, it adds an additional home screen widget, rather than replacing the first home screen widget.
0
0
424
Nov ’22
Can not install app on iPhone
Can someone translate this: Details SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.just.Memory-Widget.Free-Memory' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0xac8a1f810 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.just.Memory-Widget.Free-Memory)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.just.Memory-Widget.Free-Memory)}}, FBSOpenApplicationRequestID=0x9949, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}." UserInfo={NSLocalizedDescription=Failed to show Widget 'com.just.Memory-Widget.Free-Memory' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0xac8a1f810 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.just.Memory-Widget.Free-Memory)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.just.Memory-Widget.Free-Memory)}}, FBSOpenApplicationRequestID=0x9949, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}., NSUnderlyingError=0xac8a1f660 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0xac8a1f810 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.just.Memory-Widget.Free-Memory)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.just.Memory-Widget.Free-Memory)}}, FBSOpenApplicationRequestID=0x9949, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}}} Domain: DTXMessage Code: 1 User Info: { DVTErrorCreationDateKey = "2022-11-04 16:37:45 +0000"; } System Information macOS Version 12.5 (Build 21G72) Xcode 14.1 (21534.1) (Build 14B47b) Timestamp: 2022-11-04T09:37:45-07:00
0
0
644
Nov ’22