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 not yet marked as solved
2 Replies
437 Views
iPhone 16.0 16.0.2 系统上运行小组件出现问题, 其他系统没有问题 SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.jiduauto.iphone.jdcomiphoneWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=5 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedDescription=The request to open "com.apple.springboard" failed., NSLocalizedFailureReason=Unexpected error type., NSUnderlyingError=0x600002bbd7a0 {Error Domain=BSServiceConnectionErrorDomain Code=3 "XPC error received on message reply handler" UserInfo={BSErrorCodeDescription=OperationFailed, NSLocalizedFailureReason=XPC error received on message reply handler}}, BSErrorCodeDescription=InvalidResponse}." UserInfo={NSLocalizedDescription=Failed to show Widget 'com.jiduauto.iphone.jdcomiphoneWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=5 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedDescription=The request to open "com.apple.springboard" failed., NSLocalizedFailureReason=Unexpected error type., NSUnderlyingError=0x600002bbd7a0 {Error Domain=BSServiceConnectionErrorDomain Code=3 "XPC error received on message reply handler" UserInfo={BSErrorCodeDescription=OperationFailed, NSLocalizedFailureReason=XPC error received on message reply handler}}, BSErrorCodeDescription=InvalidResponse}., NSUnderlyingError=0x600002bbd5f0 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=5 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedDescription=The request to open "com.apple.springboard" failed., NSLocalizedFailureReason=Unexpected error type., NSUnderlyingError=0x600002bbd7a0 {Error Domain=BSServiceConnectionErrorDomain Code=3 "XPC error received on message reply handler" UserInfo={BSErrorCodeDescription=OperationFailed, NSLocalizedFailureReason=XPC error received on message reply handler}}, BSErrorCodeDescription=InvalidResponse}}} Domain: DTXMessage Code: 1 User Info: { DVTErrorCreationDateKey = "2024-02-19 08:02:14 +0000"; } System Information macOS Version 13.5.2 (Build 22G91) Xcode 15.0 (22265) (Build 15A240d) Timestamp: 2024-02-19T16:02:14+08:00
Posted
by
Post not yet marked as solved
0 Replies
295 Views
Hi, I have few questions regarding the widgets. I would like to know whether widget and app extensions are same ? This link(https://developer.apple.com/app-extensions/) says widget is type of app extension but I am not quite sure as few link in web says they are different. so need to confirm here :) Can a widget share same bundle id as the main app ? so basically can we use the same provisioning profile as the main app? If we use the same bundle id and provisioning profile, will there be any issue during the app store submission process.?
Posted
by
Post not yet marked as solved
0 Replies
170 Views
There is a code: func getData() async -> [Data] { do { let token = try ServiceData.getTokenThrows() let listData = try await ServiceData.fetchDataNew(token: token) // always return list data return listData } catch { return [] } } func entities(for identifiers: [DataModel.ID]) async throws -> [DataModel] { return await getData().filter { identifiers.contains($0.id) } } func suggestedEntities() async throws -> [DataModel] { return await getData() } func defaultResult() async -> DataModel? { return await getData().first } } Sometimes during assembly, when changing user data, the data in WidgetConfiguration Intent @Parameter is not received, although they are in the console, and EntityQuery methods do not throw exceptions. Does anyone have any ideas?
Posted
by
Post not yet marked as solved
0 Replies
350 Views
Is there a way to migrate WidgetKit extensions made using dual-target watchOS apps to single-target apps? When you create a widget extension with a dual-target app, the bundle identifier includes the extra extension domain (com.company.app.watchkitapp.watchkitextension.widgets). When Xcode 15 migrates a dual-target to single-target, it removes “.watchkitextension” from both the watchOS app bundle identifier and the widget extension bundle identifier. watchOS seems to handle migrating the main app just fine, but any complications created with the dual-target do not get migrated and are just blank until the user re-configures, which would be a huge bummer to have to ship. If I try to manually set the bundle identifier back to include “.watchkitextension”, the OS rejects the installation because of the extraneous dot after the parent app’s prefix.
Posted
by
Post not yet marked as solved
0 Replies
267 Views
Hello. My project includes a widget target that provides interactive widget functionalities. The document "Adding Interactivity to Widgets and Live Activities" says the following: Additionally, note that the perform() function is marked as throws. Be sure to handle errors instead of rethrowing them, and update your app, widget, and Live Activity as needed. For example, update a widget’s interface to indicate that it displays outdated information if it cannot load new data. https://developer.apple.com/documentation/widgetkit/adding-interactivity-to-widgets-and-live-activities#Implement-the-perform-function, column 3 However, I couldn't find a way how to handle an error in an interactive widget. The Button(intent:) and Toggle(intent:) initializers don't have mechanisms for error handling. Does anyone know a solution for handling errors in interactive widgets?
Posted
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
Post not yet marked as solved
2 Replies
540 Views
I'll preface this to say that I'm not 100% sure this is all accurate, but I wanted to share this problem I was seeing developing a widget for a SwiftUI app in case it helps someone else get to a solution faster. Two weeks ago I released a version of an app which contained a brand new widget. For the kind property of the widget's configuration I just used something generic: AppWidget. Last week we wanted to add an additional widget into the app and I realized that I ought to make the kind be a little more specific. So I renamed the first kind from AppWidget to DailyPromptWidget ... and made the second widget use a kind named DailyCheckInWidget. Then, we started seeing issues where the widget wasn't responding to taps and would eventually go blank. I could add in a new widget to the home screen and that'd work fine. Searching the Internet for ideas yielded nothing. I connected my iPhone to my Mac and launched the Console app and then started tapping on the non-responsive widget. I discovered a few output messages like this: Timeline[my.bundle.id::my.bundle.id.widgetid:AppWidget:systemMedium::338.00/158.00/21.60:(null)]--CD0C49416486::0xc46382000) Unable to create CHUISWidgetLaunchRequest without a effectiveContainerBundleIdentifier I was able to reproduce the issue by renaming the bundle ID of the widget (and leaving the working widget on the home screen). Tapping it gave the same exact error. Another error, which clued me in more: Content load failed: unable to find or unarchive file for key: [my.bundle.id.widgetid:AppWidget:systemMedium::338.00/158.00/21.60:(null)] on no host. The session may still produce one shortly. Error: Using url `file:///private/var/mobile/Containers/Data/PluginKitPlugin/012DB9D2-07F7-4383-9CCE-B040652B7999/SystemData/com.apple.chrono/placeholders/AppWidget/systemMedium----338.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline` ... Error Domain=NSCocoaErrorDomain Code=4 "The file "systemMedium----338.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline" doesn't exist." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/PluginKitPlugin/012DB9D2-07F7-4383-9CCE-B040652B7999/SystemData/com.apple.chrono/placeholders/AppWidget/systemMedium----338.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline, NSUnderlyingError=0x3025a1d10 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} So, I tried finding those files in the simulator data on my Mac. Inside the placeholders/ directory are directories with the names of all the widget kind I had used (the old and the new). Inside those named kind directories are, what look to be, files representing each timeline entry. It appears that if you change the kind string in your widget's configuration, the widget you've added to your home screen does not get updated and will continue looking for the old timeline entry files in the original kind directory. The solution? Either don't rename the kind once you've released it on the App Store, or instruct customers to remove the widget and add it back after they've installed your app update. It'd be nice if an app update would also update the kind directory name.
Posted
by
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
by
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
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
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
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
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
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
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