I recently built a widget with WidgetKit. When I bulding app from Xcode on the simulator widget appears, but when I install app from TestFlight widget is missing. Does anyone know what might have happened to widgets in iOS 18 that could cause this issue? By the way, it works for me in the Simulator but not on a real device.
WidgetKit
RSS for tagShow 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.
Posts under WidgetKit tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Does anyone else have a problem that with iPad OS18.2 beta, its not possible to set or change the wallpaper either from the lock screen or from settings.
Alost means that you can’t add Widgets to the lock screen.
Is this a bad update on my iPad or is this a bug?
Hi,
Firstly: The whole question is about MacCatalyst (in IOS it works as intended)
In my Maccatalyst app I want to share Userdefaults between app and widget. I have added an app group to the widget and the app and have set up Userdefauls accordingly.
Here is the problem:
Xcode claims that the app group should start with "group.***" because Catalyst is based on iOS. If I do so, my Catalyst app rises the "App wants to access data from other apps" requester on EVERY launch. So, I can't use it in production. Even if I would accept the requester, the widget isn't able to access the defaults at all because it does not rise that requester, but silently ignores the access.
In contrast, if I setup the app group name with our TeamID (instead of group.*) then the requester vanishes, but Xcode does not accept it, issuing a warning and displaying the app group in red. I don't think this is advisable 'state' for production code. Even then widget can't see the data either.
What is the recommended way of sharing Userdefaults between Catalyst app and Catalyst Widget (not the iOS widget which displays the "open on iPhone warning" when clicked) on macOS ?
Thanks
How to play gif in widget? "网易云音乐" and "one widget" can play gif in the widget. can anyone guide me. Thank you
I want to share UserDefaults between main App and macOS Widget, in iOS I can do it using AppGroups, but how to do it between macOS Widget and main App, because macOS widget's AppGroup require to use "Team Identifier" as prefix and main App's AppGroup require prefix to be "group" so how can I share UserDefaults between the two?
In iOS18 the user can change their Home Screen customization to choose either light, dark, or tinted. If they choose tinted the widgets are rendered using the "accented" rendering mode and without a background.
Is there some way to override so that the tinted mode is ignore completely and the widgets render as full color?
I know about WidgetAccentedRenderingMode (https://developer.apple.com/documentation/widgetkit/widgetaccentedrenderingmode) but that's only for images, not the whole control and doesn't help with the background also being removed in the tinted mode.
macOS: Sequoia
Xcode: 16.1
I am working on a macOS app and it has a widget feature.
When I use Swift 6 (Build Settings > Swift Language Version) in IntentExtension, the intent configuration won't show up in macOS Sequoia.
If I downgrade to Swift 5, it works without any other changes.
Is it a bug or am I missing something? How can I use Swift 6 with IntentExtension.
I created an Intent-based widget for my iOS app. The deployment target is iOS 16, but I stick to Intent vs AppIntent because I don't like how the configuration list pops up vs the list with search in the old API.
So, the configuration works fine on iOS 17/18, but iOS 16 shows the error "unable to load" or just a blank view.
This is how it looks on iOS 17/18
I don't see any specific errors in a console or warnings.
I made a LockScreen ControlWidget with CameraCaptureIntent, but I found launch my main app from Control Widget, SceneDelegate will be called like below:
sceneWillEnterForeground
sceneDidBecomeActive
sceneWillResignActive
sceneDidBecomeActive
sceneWillResignActive be called, is it normal?
it make my app camera launch with a delay.
I created an intent for a configurable widget that lets users choose an option for a parameter called "domain."
I've successfully loaded the selectable items for this parameter using the following code:
import Intents
class IntentHandler: INExtension, ConfigChartIntentHandling {
func provideDomainOptionsCollection(for intent: ConfigChartIntent) async throws -> INObjectCollection<Domain> {
let prefs = UserDefaults(suiteName: "group.name")
let domains = prefs?.stringArray(forKey: "domains")
if let domains {
let optionsCollection = domains.map { Domain(identifier: $0, display: $0) }
return INObjectCollection(items: optionsCollection)
} else {
// If no options, provide an empty list or a default option
return INObjectCollection(items: [])
}
}
}
The issue occurs when I select a value for the "domain" parameter. Each time I select a value and then reopen the configuration modal, the field reverts back to "Choose." Here's a screenshot illustrating the behavior:
Additionally, the widget doesn’t refresh after I change the "domain" value. However, another parameter using an enum ("Stats Type") works as expected.
Is there something I might be missing?
My Environment:
MacOS Sonoma
XCode 15.4
Xcode: 16.1
macOS: Sequoia
When I run widget preview, I got the following errors
CoreData: error: Store failed to load. <NSPersistentStoreDescription: 0x156237310> (type: SQLite, url: file:///Users/user/Library/Group%20Containers/group.com.app.name/Library/Application%20Support/default.store) with error = Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be opened." UserInfo={reason=Unknown failure to access file: 1} with userInfo {
reason = "Unknown failure to access file: 1";
}
Unresolved error loading container Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be opened." UserInfo={reason=Unknown failure to access file: 1}
with this code
let sharedModelContainer: ModelContainer = {
let schema = Schema([Company.self, Person.self])
do {
return try ModelContainer(for: schema, configurations: [.init(isStoredInMemoryOnly: false)])
} catch {
fatalError("error: \(error)")
}
}()
Does anyone know why this happens and how to fix this?
When I try to access the data in my IntentTimelineProvider in the recommendations function using App Groups, it is always empty "no data".
func recommendations() -> [IntentRecommendation<IndicatorIntent>] {
if let sharedUD = UserDefaults(suiteName: "group.measurements") {
let jm = JanitzaMeasurementValue(identifier: "1", display: "2")
let intent = IndicatorIntent()
intent.indicatorWidgetData = jm
let desc = sharedUD.string(forKey: "string") ?? "no data"
return [IntentRecommendation(intent: intent, description: desc)]
}
return []
}
Although I write this in both the watchOS and iOS app using App Groups.
if let sharedUD = UserDefaults(suiteName: "group.measurements") {
sharedUD.set("test", forKey: "string")
}
What is the right way to dynamically implement the widgets for Complications in watchOS?
Like for example in Shortcuts App.
**Thanks for support **
When the text is set to non-accentable, it always appears white. The background is accentable, but when the user changes the tint color to white, the text becomes invisible.
How can I make it work like in the Shortcuts widget, where the text color automatically changes based on the tint of the background, ensuring the text is always visible?
https://developer.apple.com/documentation/WidgetKit/Adding-interactivity-to-widgets-and-Live-Activities#Add-a-toggle
Before explaining the situation, I referred to this document.
I'm making a widget with a toggle that works with Intent. (To be precise, it's Live Activity, but Apple's literally toggling and button interaction are implemented in the same way)
If you press the toggle when the device is locked, the toggle represents the state.
However, as described at the top of the same document, the device must be unlocked to execute Intent, so I can't actually change the data.
That's fine, but how can I return the isOn of the toggle to false? I'm blocked here because no code is executed.
If it is a widget in the home screen, it will be basically unlocked, so I can proceed according to the method of the document, but if it is today's view, user can access it even if device is locked.
I tested it in today's view with the Reminders app, If I don't unlock the device after tapping the toggle it returns the toggle back to false state.
I wonder how I can achieve this.
Is there an API that I missed?
Summary.
Tap the toggle of the widget while the device is locked.
The device waits for unlocking, but the user cancels it without unlocking it. (Still locked)
Return the isOn of the toggle to false. <- The part I want.
Hello. I am having trouble trying to create a control in control center view that opens a specific view in my app using AppIntents (iOS18 )and WidgetKit, can someone help me please? I feel like the original videos and documentations are incomplete.
Hello.
We have multiple WidgetKit extensions in our application. in IOS18 there is option to transform app icon into widget by long press on icon.
Is there any way to setup default WidgetKit extension that icon will be transformed to?
Hello,
I am trying to create a custom control with the new WidgetKit control widget APIs.
In my custom control, I want to display a custom image, in fact a custom symbol. The custom symbol is not displayed with latest iOS 18 Seed 7 (22A5346a). Only system symbols are displayed. I don't find any information about it in the WidgetKit Apple Developer Documentation.
ControlWidgetButton(action: MyIntent()){
Label(title: {
Text("My Custom Control")
}, icon: {
Image("mycustomsymbol") //NOT DISPLAYED
// Image(systemName: "rectangle.portrait.inset.filled") IS DISPLAYED
})
}
There was no issue with custom symbols in beta 4. Now since beta 5, custom symbols are not displayed.
I wonder if this is a bug or this is intended.
Can you help me ?
I filed a feedback FB14888220
Thank you
Hi devs,
my app has control center widgets and interactive widgets, both are using the same app intent to update sharing status (App Group's UserDefault).
When the app is running in the background, control center widget and interactive widgets can be reloaded with correct status. However, if the app is not running in the background, I tap the interactive widget and the interactive widget can reload with correct status but the control center widget can't. Vice versa, the control center widgets can reload with correct status but the interactive widgets can't.
struct ChangeAppStatusIntent: AudioRecordingIntent, CustomIntentMigratedAppIntent, PredictableIntent, LiveActivityIntent, SetValueIntent {
... // data and setup
@MainActor
func perform() async throws -> some IntentResult {
// change the AppGroup data for app status
WidgetCenter.shared.reloadAllTimelines()
ControlCenter.shared.reloadAllControls()
}
}
does any way to fix this issue?
Environment
Xcode: 16.1
Swift 6 and SwiftUI for macOS development
macOS Sequoia
I have an app for macOS, and that uses an interactive widget feature.
On macOS Sequoia, the widget does not display anything and widget intent doesn't work either. I tested it on macOS Sonoma and it totally works. I assume it's a macOS bug. The app has been working fine before Sequoia.
Even on Xcode, when I tried to run the widget preview, Failed to load widget. The operation couldn't be completed. (WidgetKit_Simulator.WidgetDocument.Error error 4.).
I could avoid the error by changing version and build numbers, but I still got The operation couldn't be completed. (CHSErrorDomain error 1103.)
How am I able to fix the issue? I wanna at least know if its a bug from the app or macOS Sequoia.
The app added control widgets and crashed online。
SwiftU!
static ControlWidgetConfigurationAdaptor._makeWidgetConfiguration(widget inputs:)