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
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
351 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
731 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
372 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
302 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
.
Post not yet marked as solved
0 Replies
200 Views
The problem is: I have some widgets at different XCode targets (as a result at different widget bundles). Bundles have different permissions, so I can't place all wisgets at the same bundle. I want to order widgets from different bundles at a custom order at Add Widget Screen. But I have different orders at different devices with different iOS versions and it is unwanted behaviour for my app. I want to have the same custom order for all widgets from different WidgetBundles
Posted Last updated
.
Post not yet marked as solved
0 Replies
404 Views
I have a countdown/up timer in a widget, and I want to format the timer to something more readable than the default that Text.init(myDate, style: .timer) provides. The default outputs a timer for just the hours in the date range. So, for example, a timer of 1 week, 5 hours, 12 minutes and 45 seconds will appear as 173:12:45 (which is 7 * 24 + 5 = 173) - not very user-friendly. An ideal output would be 1 week 05:12:45. Is there any way of doing that? I've tried a number of different ways using TimeInterval, DateInterval, and modding (%) values - like modding the hours count by 168 to get a number of weeks - but they're pretty much useless when there are never a set number of days or weeks in a year due to leap years. It would be great if you would provide actual code examples rather than saying to use a certain API, as I could very easily go down a rabbit hole like I have with TimeInterval and DateInterval. Thanks!
Posted
by darkpaw.
Last updated
.
Post not yet marked as solved
0 Replies
322 Views
I read in official documents that there is a height range of 84-160. But when I preview, it is always fixed at a certain height. What should I do to make the height of DynamicIslandExpandedRegion grow dynamically according to the content?
Posted Last updated
.
Post not yet marked as solved
0 Replies
344 Views
we know ios support widget added through home screen by user, i want to know can ios support widget added by api like android? best wishes! https://developer.apple.com/design/human-interface-guidelines/widgets
Posted Last updated
.
Post not yet marked as solved
3 Replies
504 Views
My widget will not load on my simulator or devices with IO7 17.2 I am getting preview error "Widget needs to adopt containerBackground". The background image is called "bg" and code is below, how do I fix this issue? var body: some View { ZStack{ Image("bg") .resizable() .aspectRatio(contentMode: .fill) VStack{ Text(entry.namazName) .foregroundColor(Color.white) .font(.custom("HelveticaNeue-Medium", size: 24)) Spacer() .frame(height: 8) Text("B: " + entry.startTime) .foregroundColor(Color.white) .font(.custom("HelveticaNeue-Medium", size: 22)) Text("J: " + entry.jamatTime) .foregroundColor(Color.white) .font(.custom("HelveticaNeue-Medium", size: 22)) } } }
Posted
by mequba.
Last updated
.
Post not yet marked as solved
1 Replies
370 Views
My guess is no... but, I have to ask. I made a widget that checks our GitHub repository for new pull requests - in an attempt to make sure PRs are addressed quicker. It works great - using GitHub's API. It's on my iPhone's Lock Screen. It definitely keeps me more on top of our pull requests! Our product manager asked if we could also send a local notification when there's a new PR. I was thinking maybe from the widget - it's updating around every 15 minutes - and if there's a new PR - then maybe it could fire a local notification. However, there's the permissions. The user has to say "OK" to them. Widget can't do that. Can it inherit the notification permissions from the parent app? Anyway - I think it is way overkill - I mean we have a widget! Why a notification as well!?!?!? I thought I'd ask... Thanks, Scott iOS 17.
Posted
by Shorty16.
Last updated
.
Post not yet marked as solved
2 Replies
742 Views
I have Rectangular, Circular and Inline and home screen widgets in my application. After updating to iOS 17.2 , only blank screen is seen in place of widgets. Any suggestions or finding would be helpful to resolve this issue.
Posted
by AKarthika.
Last updated
.
Post not yet marked as solved
0 Replies
539 Views
Hello Apple Community, I am writing to discuss a limitation I’ve encountered with third-party alarm clock apps on iOS. As it stands, these apps are unable to function like the native Clock app, primarily due to the restrictions imposed by the operating system. Currently, third-party alarm apps rely on standard local notifications, which fire once and then cease. This means that if a user misses the initial notification, there’s no backup mechanism to ensure they are alerted. This is a significant drawback for users who rely on these apps to manage their time effectively. Moreover, some apps have found a workaround by playing a silent sound in the background to keep the app active. However, this method is not only against Apple’s guidelines but also drains the device’s battery life. I propose that Apple consider allowing third-party apps to push notifications from the background in an alarm style, with clear permissions granted by the user. This would enable users to clearly define acceptable notifications and specify an alarm-like display, providing a more personalized and effective alarm experience. By implementing this change, Apple could greatly enhance the functionality and user-friendliness of third-party alarm clock apps, ultimately benefiting the end-users and developers alike. Because this alarm feature is so important for productivity and quick responses to critical events or triggers I'm trying to see how some concepts could be reimagined if we had a little more flexibility. Apple iOS has a feature called StandBy mode that activates when an iPhone is charging and positioned on its side. This feature can be thought of as a kind of smart display for your iPhone that offers fast access to different screens of glanceable information. Always-On Display: StandBy mode can keep the display on even when the phone is locked, which is useful for an alarm app. Users can glance at the time without having to unlock their phone w/ Low-Light Adaptation Customizable Screens: StandBy mode consists of screens that can be accessed by swiping horizontally on your iPhone’s display. This could allow an alarm app to display additional information, such as route, or weather warnings. Interactive Widgets: The widget screen in StandBy mode is interactive and customizable. I look forward to hearing your thoughts on this matter. Best regards, Phil Cutting
Posted Last updated
.
Post not yet marked as solved
1 Replies
299 Views
Hello, I'm researching the functionality of widgets and came across a question while reading the official documentation. According to the following link, it says, "Coordinate the corner radius of your content with the corner radius of the widget." https://developer.apple.com/design/human-interface-guidelines/widgets#Previews-and-placeholders Does this mean that the framework of the widget should have rounded corners, and it is not necessary for Views within the widget to always have rounded corners? For example, if I want to place a square image in the widget, do I need to implement it so that the image has rounded corners? If anyone knows, could you please provide some guidance? Thank you very much.
Posted
by suzukiyut.
Last updated
.
Post not yet marked as solved
34 Replies
18k Views
I'm trying to create an iOS 14 WidgetKit widget. It's compiling, but when I try to run it, on either simulator or device, I get the error below: Any suggestions on how to debug this? Details SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.myapp.dev.WidgetKitExtension' error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)}." UserInfo={NSLocalizedDescription=Failed to show Widget 'com.myapp.dev.WidgetKitExtension' error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)}., NSUnderlyingError=0x7fc0b0d12540 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)}}} Domain: DTXMessage Code: 1- System Information macOS Version 10.15.5 (Build 19F101) Xcode 12.0 (17177)
Posted
by jackpal.
Last updated
.
Post not yet marked as solved
0 Replies
465 Views
Hello, I'm working on my first app. It's also my first encounter with App Intents. I have a data structure for events that has an ID (String), a name (String), a Date and an image (Data). The user can create them in the app and they are stored with CoreData. I wanted to have a widget that would allow the user to choose from their list of events and display that event in the widget. The list should appear in the widget configuration and it would be a list of the names and (if possible) the image. I think I have found how to access the information from the widget, but I cannot figure out how to have the list appear in the configuration. I have been following this guide: https://developer.apple.com/documentation/widgetkit/making-a-configurable-widget?utm_source=pocket_saves. But that one shows hardcoded elements in the list and I haven't been able to find how to have the list change in relation to the content of the app. This is what I have made so far in the AppIntent file: import WidgetKit import AppIntents import CoreData struct EventDetail: AppEntity { static var defaultQuery: EventQuery = EventQuery() var id: String var date: Date var image: Data var title: String static var typeDisplayRepresentation: TypeDisplayRepresentation = "Event" var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(id) \(title)") } } struct EventQuery: EntityQuery{ func entities(for identifiers: [EventDetail.ID]) async throws -> [EventDetail] { return fill_event_details(events_list: getEventDataIntent()) } func suggestedEntities() async throws -> [EventDetail] { fill_event_details(events_list: getEventDataIntent()).filter { $0.id != "-" } } func defaultResult() async -> EventDetail? { try? await suggestedEntities().first } } struct ConfigurationAppIntent: WidgetConfigurationIntent { static var title: LocalizedStringResource = "Select an event" static var description = IntentDescription("This is an example widget.") // An example configurable parameter. @Parameter(title: "Event") var event: EventDetail // init(events: [UserCountdowns]) { // self.event = fill_event_details(events_list: events)[0] // print("AppIntent") // print(self.event.title) // } init() { } } func fill_event_details(events_list: [UserCountdowns]) -> [EventDetail] { var entities_list: [EventDetail]? let events = getEventDataIntent() for event in events { entities_list!.append(EventDetail(id: event.id!, date: event.date!, image: event.image!, title: event.title!)) } return entities_list ?? [EventDetail(id: "-", date: Date(), image: Data(), title: "empty")] } func getEventDataIntent() -> [UserCountdowns] { let context = PersistenceController.shared.container.viewContext let request = UserCountdowns.fetchRequest() var result: [UserCountdowns]! do { result = try context.fetch(request) } catch { print(error) } return result } I have been trying a few things in the widget's code but I haven't been able to make anything work, so I don't really have anything worth sharing, I think. This is the code for the UserCountdowns structure: extension UserCountdowns { @nonobjc public class func fetchRequest() -> NSFetchRequest<UserCountdowns> { return NSFetchRequest<UserCountdowns>(entityName: "UserCountdowns") } @NSManaged public var date: Date? @NSManaged public var image: Data? @NSManaged public var title: String? @NSManaged public var id: String? } Could anyone help me with this, please? What am I missing or what would the next step be? Let me know if there is any other part of the code I should share. Thank you in advance!
Posted Last updated
.
Post not yet marked as solved
1 Replies
279 Views
Hi team, I see there is a new protocol PlayVideoIntent, how to use it in iOS17.2. Is that I mean I can play video on a widget? Thank you for your reply
Posted Last updated
.
Post not yet marked as solved
0 Replies
221 Views
I have a requirement where I have enabled the widget for my app but I don't want to show it to some specific user. And on click of any button on my app, I can enable the widget for that user. Basically I can pass the value to supportedFamilies(_:) on runtime? Any help will be appreciated
Posted Last updated
.