WidgetKit

RSS for tag

Show relevant, glanceable content from your app on iOS and iPadOS Home Screen and Lock Screen, macOS Desktop, Apple Watch Smart Stack and Complications, and in StandBy mode on iPhone.

WidgetKit Documentation

Posts under WidgetKit tag

311 Posts
Sort by:
Post marked as solved
1 Replies
356 Views
In my app, there's a widget that should change to one color when clicked and then to another color after 10 seconds. When I click the widget button (linked to the App Intent), the widget should refresh. When I debug, this happens as expected. However, if I call WidgetCenter.shared.reloadAllTimelines() in the perform() method of AppIntent, the widget timeline doesn't refresh right away. This issue only happens on real devices and isn't always consistent. In the simulator, the widget refreshes as expected.
Posted
by Ezio211.
Last updated
.
Post not yet marked as solved
0 Replies
368 Views
WidgetKit library was presented appeared on WWDC20, and since then there has been no way to bring users to the Widget Gallery, and this becomes a stumbling block for many developers, since we are not able to send our users to developed widgets I suggest Apple add a custom URL scheme similar to that for system applications: facetime://user@example.com sms:1-111-111-0037 And this URL Scheme is up to Apple, but there is a few thoughts about it: How the URL might look like: widgetgallery: widgetgallery:type=<...>&family=<...> URL Scheme parameters: type - widget's kind string identifier, defined in app family - family of widget This will help make widgets more common among users, as well as increase conversion in their additions. For this reason, the development of widgets will become an appropriate feature for companies
Posted Last updated
.
Post not yet marked as solved
1 Replies
285 Views
Hello all, Is there any best practice how it's possible to add native visionOS support for existing app, that already includes WidgetKit extension, where both targets should share some files? "Your target is built for visionOS but contains embedded content built for the iOS platform (WidgetsExtension.appex), which is not allowed" Thanks a lot!
Posted
by DudiSG.
Last updated
.
Post not yet marked as solved
1 Replies
235 Views
I added a spotify widget on the first page of my home screen. That widget is working fine and totally normal. On the second page of my home screen, there is another widget floating with the little minus sign like when you add or delete an app/widget on your screen. My apps sit on top of it, I can't move it, I can't delete it. Anyone dealt with this before?
Posted
by carocat.
Last updated
.
Post not yet marked as solved
38 Replies
8.2k Views
Hi, In my apps, the recent iOS 16.0 beta 7 (20A5356a) broke the .timer DateStyle property of the Text view, in a SwiftUI widget. In previous OS and beta, Text(Date(), style: .timer) was correctly displaying an increasing counter. In iOS 6.0 beta 7, Text(Date(), style: .timer) does not update anymore, (and is offset to the left). The other DateStyle (like .offset, .relative, ...) seems to update correctly. Anyone noticed that (very specific) problem ?
Posted
by PacoLabs.
Last updated
.
Post not yet marked as solved
2 Replies
544 Views
⌚️Hello, I've noticed in watchOS 10 that when a complication is in the Smart Stack, the value of WCSession.isComplicationEnabled is false. I'm not sure if this is intentional or a bug. It seems trivial at first glance, but it actually affects the communication mechanism mentioned in Implementing Two-Way Communication Using Watch Connectivity. In the following two scenarios, if the user has only added the app's complication to the Smart Stack, then the watch app will not be able to communicate properly with the iOS app. Scenario 1 - WCSession.transferCurrentComplicationUserInfo() // update complications from the iOS app if WCSession.default.isComplicationEnabled { let userInfoTransfer = WCSession.default.transferCurrentComplicationUserInfo(userInfo) // ... } As described in Implementing Two-Way Communication Using Watch Connectivity, when the iOS app proactively updates the data of the watch app, since WCSession.isComplicationEnabled is false, WCSession will refuse to transfer any data. This causes the standalone complication in Smart Stack to not be updated. Scenario 2 - WKApplicationRefreshBackgroundTask When the watch app uses WKApplication.scheduleBackgroundRefresh() to periodically update data, as long as the user has added the app's complication to the watch face, the corresponding WKApplicationRefreshBackgroundTask can be executed periodically in the background to fetch data. However, if the user has only added complication to the Smart Stack, then the watch app will be completely purged, and the background task will not be executed at all. Although WCSession.isComplicationEnabled is not directly used in this scenario, its behavior appears to be the same, that is, the complication in the Smart Stack is not considered a complication by the system. Should I submit a bug report?
Posted
by Gong.
Last updated
.
Post not yet marked as solved
2 Replies
354 Views
Environment: iOS Version: 17.2 iOS Simulator Version: 17.2 Xcode Version: 15.2 Device: iPhone 15 Pro Max App Target Version: iOS 17.2 Preconditions: App with Live Activity feature is installed. Device/Simulator is running iOS 17.2. Steps to Reproduce: Start the app and initiate a Live Activity with text styled as .timer. Lock the device screen or switch to the lock screen view in the iOS Simulator. Observe the Live Activity on the lock screen, noting the text style. Unlock the device. This time noting the .timer changed its style. The text style of the Live Activity remains consistent both on the lock screen and after unlocking the device, maintaining its .timer style throughout its lifecycle. Frequency: Occurs every time the steps are reproduced.
Posted
by Qwadrox.
Last updated
.
Post not yet marked as solved
0 Replies
365 Views
I am facing an issue with the .after policy in SwiftUI Timeline. The update is not occurring at the exact time I have specified; there are delays ranging from 5 minutes to 3 minutes, etc. How can I resolve this issue? What can I do to ensure that the update happens precisely at the specified time without any delay? Code Example: struct SimpleEntry: TimelineEntry { let date: Date } func getTimeline(in context: Context, completion: @escaping (Timeline<SimpleEntry>) -> Void) { // For example, a future date and time: 2024-02-01 12:00:00 let refreshDateComponents = DateComponents(year: 2024, month: 2, day: 1, hour: 12, minute: 0, second: 0) // Create a Date object using the specified date and time if let refreshDate = Calendar.current.date(from: refreshDateComponents) { // Create a SimpleEntry using the generated Date object let entry = SimpleEntry(date: refreshDate) // Create a Timeline and perform the completion with it let timeline = Timeline(entries: [entry], policy: .after(refreshDate)) completion(timeline) } // Return an empty Timeline in case of an error else { let emptyTimeline = Timeline(entries: [], policy: .never) completion(emptyTimeline) } }
Posted
by meviza.
Last updated
.
Post not yet marked as solved
0 Replies
246 Views
I see this warning a lot in console.log when my widgets update, is it just noise or is there something I could be doing wrong in my widgets. I don't do anything explicitly with the runloop in my code, it's just regular SwiftUI to render a widget.
Posted
by markdaws.
Last updated
.
Post marked as solved
10 Replies
1.6k Views
I'm looking to migrate my users ClockKit complications to WidgetKit in my next app update. I can only do this for WatchOS 10 users because the APIs are too limited for WatchOS 9 (eg. Widget corner round text not available). But I do need to do this for WatchOS 10 users in order to get in the Smart Stack. When I tried to mark my getWidgetConfiguration method in my ComplicationController.swift with: @available(watchOS 10.0, *) it complains and says: Protocol 'CLKComplicationWidgetMigrator' requires 'getWidgetConfiguration(from:completionHandler:)' to be available in watchOS 9.0 and newer I then tried modifying my WidgetKit extension to only support WatchOS 10. This seems to work for a while but at some point WatchOS 9 devices still try the migration and crash with symbolNotFound DYLD issues for the WidgetKit extension which shouldn't even be embedded in the WatchOS 9 builds! (all visible in iPhone Analytics data crashes) So I'm not sure what else to try. I've researched a lot in docs etc... but can find no official way to achieve this.
Posted Last updated
.
Post marked as solved
1 Replies
1.1k Views
I have a Xcode project with a widget extension, Xcode, simulator and terminal are running with Rosetta (I can't change this). When I build and run the main project, the widget does not get loaded on the widgets list, when running the widget scheme on Xcode the app crashes when loading the application on simulator. Same happens on device. Macs with Intel silicon run it okay. Xcode without rosetta is also okay. Xcode log window shows the following message: SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'Gabriel.Widget-Rosetta.Widget' error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (Gabriel.Widget-Rosetta.Widget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (Gabriel.Widget-Rosetta.Widget)}." UserInfo={NSLocalizedDescription=Failed to show Widget 'Gabriel.Widget-Rosetta.Widget' error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (Gabriel.Widget-Rosetta.Widget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (Gabriel.Widget-Rosetta.Widget)}., NSUnderlyingError=0x600001106010 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (Gabriel.Widget-Rosetta.Widget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (Gabriel.Widget-Rosetta.Widget)}}} Domain: DTXMessage Code: 1 User Info: {     DVTErrorCreationDateKey = "2022-07-06 14:45:31 +0000"; } -- System Information macOS Version 12.2.1 (Build 21D62) Xcode 13.2.1 (19586) (Build 13C100) Timestamp: 2022-07-06T15:45:31+01:00 Console shows the following message: libc++abi: terminating with uncaught exception of type NSException dyld4 config: DYLD_FRAMEWORK_PATH=/Users/gabriel.soria/DD/Widget-Rosetta-bhlamdqmnxdfvtapitjtbxxspnfc/Build/Products/Debug-iphonesimulator DYLD_LIBRARY_PATH=/Users/gabriel.soria/DD/Widget-Rosetta-bhlamdqmnxdfvtapitjtbxxspnfc/Build/Products/Debug-iphonesimulator DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSXPCDistantObject ___nsx_pingHost:]: unrecognized selector sent to instance 0x600003948aa0' _LSContextInitReturningError() failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xf6701f12 bb1a56bb bba5f39f 3f7801a6 ... f9fe6ee0 ef307d24 }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x9da4b2b1 56f7ac19 1a99bc21 b7ec95c2 ... c4004d14 03ef83dc }} terminating with uncaught exception of type NSException CoreSimulator 783.5 - Device: iPhone SE (2nd generation) (E360DB1E-33FF-45A4-926C-A6093DFB3699) - Runtime: iOS 15.2 (19C51) - DeviceType: iPhone SE (2nd generation)
Posted
by macbieoo.
Last updated
.
Post not yet marked as solved
1 Replies
328 Views
Whenever I try to put my choice of time zones on the MacBook clock widget, it won't show on the main widget. It will show the stock clock options. Such as Cupertino, Tokyo, Sydney, and Paris, Even though I change them inside the app the widget won't display the changes.
Posted
by sakeeb07.
Last updated
.
Post not yet marked as solved
3 Replies
698 Views
Hello, I created a lock screen widget for my app last year, as a widget app extension. It has worked fine, but I am working on a new release and it has stopped updating: It is not called anymore when I call WidgetCenter.shared.reloadTimelines(ofKind: "MyWidget"), and the preview screen is now blank when I add it on the lockscreen. I haven't touched anything related to the widget from what I know. The only things I can think of is that Xcode has updated my project files automagically, and I have updated cocoapods. I looked at the device logs, and found this: [...MyWidget] Failed to launch extension with error: Error Domain=com.apple.extensionKit.errorDomain Code=2 UserInfo={NSUnderlyingError=0x84b4d4410 {Error Domain=RBSRequestErrorDomain Code=5 UserInfo={NSLocalizedFailureReason=, NSUnderlyingError=0x84b45ea30 {Error Domain=NSPOSIXErrorDomain Code=111 UserInfo={NSLocalizedDescription=}}}}}. I have no idea what this is, hoping someone can come up with suggestions on where to look. I have looked at my git history but I can't find anything changed.
Posted
by Mathias_.
Last updated
.
Post not yet marked as solved
0 Replies
345 Views
I'm in process of reimplementing my app in SwiftUI and WidgetKit. So far so good, I really like that I can finally use SwiftUI views for widgets. However, I'm having issues with AccessoryInline widget on Utility watch face. My old UtilitarianLarge complication displays in full color, but AccessoryInline widget displays only in gray - it's not even widgetAccentable on Utility watch face. I receive widgetRenderingMode from the Environment, and it shows fullColor. However, no matter how I try to apply color to the image or text, both stay gray. This widget family is not documented well (as many of things in WatchOS), and Google/ChatGPT/Bing produced zero usable results. It looks like it's a bug in WIdgetKit. If it's supposed to be displayed in Accented mode only, it should report as such in widgetRenderingMode (and support WidgetAccentable). Otherwise it should display in full color, just like the old complication.
Posted
by Eugr.
Last updated
.
Post not yet marked as solved
0 Replies
286 Views
Hi, In our tests, especially when we tested the new widgets with interactions (introduced in iOS 17), we found that sometimes they can hang when fetching data from CoreData using background context. I realise that there is no reason to use background context in widgets, but in our case we were reusing logic and so there were multiple background contexts. I'm trying to find information about using background context in widgets, but I can't find it. Now we avoid using background context in widgets, but it would be interesting to know if the use of CoreData background context in widgets is not allowed or could it be a kind of bug? Perhaps this information would be useful to anyone trying to find the cause of widget hangs.
Posted Last updated
.