Use for WidgetKit introduced in iOS 14 and macOS Catalyst 14
Questions tagged [widgetkit]
520 questions
5
votes
1 answer
SwiftUI, WidgetKit: Format date with timer style
I have a working clock widget. To achieve that, I have created a timeline that updates once a day.
func getTimeline(in context: Context, completion: @escaping (Timeline) -> Void) {
let midnight = Calendar.current.startOfDay(for:…

Luda
- 7,282
- 12
- 79
- 139
5
votes
1 answer
iOS widget always displaying placeholder on simulator or device
I'm made an very basic iOS Widget Extension with (on iOS 16):
struct TotoView: View
var body: some View {
VStack {
Text("Toto")
.font(.headline)
}
}
}
struct TotoWidget: Widget {
var body:…

chepiok
- 193
- 12
5
votes
3 answers
SwiftUI iOS Widget – Image after some time gets cropped
I am creating iOS 14+ Widget using SwiftUI and I'm facing very strange situation. Problem is that I have just one "full widget" image (maybe or not its worth noting that it's downloaded from the internet but in the time of displaying its already…

Robert Dresler
- 10,580
- 2
- 22
- 40
5
votes
1 answer
Widget not showing up in "search widgets" and im getting an error
I am using XCode 14 beta and for some reason, my widgets don't work in iOS 15, but only in 16. And Im also getting this error message:
SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8…

CoolCrafts Bayarea
- 73
- 5
5
votes
0 answers
How to use Core Bluetooth for iOS widgets?
I want to show ble service characteristic values in iOS widget like I have successfully developed app for blood pressure to show systolic and diastolic values. Well it's must that app is not running in background. Only widget update by particular…

Mashhood Qadeer
- 482
- 8
- 19
5
votes
0 answers
IOS Widgets, Identify multiple Widget with same kind
I need to create an illimited number of widgets, with the same layout, but with different behavior and content.
When the user adds many widgets of the same type, the kind will be the same. I need something else to identify the widgets in order to…

Apoleo
- 2,045
- 2
- 21
- 37
5
votes
0 answers
IOS: Add a Home Widget from inside my App
I would like to add a widget to the home screen directly from the App.
Right now the user can go from the home screen to the widgets menu, search for the app widgets and add the one he likes, but it is way more complicated than it should since the…

Apoleo
- 2,045
- 2
- 21
- 37
5
votes
0 answers
WidgetKit: How to make print statements appear in the console?
I am trying to find out why my Widget does not reload.
I want to print entries array from inside func getTimeline to the console.
However the print statements do not appear in the console.
How to make print statements appear in the console?

user14119170
- 1,191
- 3
- 8
- 21
5
votes
1 answer
iOS Today Widgets (old widgets) disappear after EVERY app update
We had "Today widgets" that worked perfect for a long time. After introducing the new Widgets Extension we added a Widgets Bundle to our app. Now after every app update the old widgets disappear from "Today view" and can be bring back ONLY by…

Stefo
- 636
- 1
- 8
- 13
5
votes
1 answer
I can't add systemExtraLarge family in WidgetConfiguration for iOS 15
I want to add an extra large widget as supported family for iOS 15 in my application.
The simplified code for WidgetConfiguration is as follows:
var body: some WidgetConfiguration {
IntentConfiguration(
kind: "Widget",
…

Tomeu Mascó
- 319
- 2
- 11
5
votes
1 answer
How to set .widgetFamily @Environment variable when NOT in a widget?
I would like to preview my WidgetKit widget in my main app.
The widget lays out differently for .systemSmall and .systemMedium sizes.
When I set .environment(\.widgetFamily, .systemSmall) in the main app I get a build error:
Key path value type…

lewis
- 2,936
- 2
- 37
- 72
5
votes
2 answers
How can I add more than 5 widgets in a widget extension? the maximum number of WidgetBundle's widget cannot exceed 5
It seems that WidgetBundle has a maximum number limit, if it exceeds 5, a compile error will be reported: Extra argument in call.
But I have not seen such a description in any document, and no other developers mentioned this issue.
Does anyone have…

qiz
- 869
- 1
- 9
- 14
5
votes
1 answer
How to load WKWebView in Widget preview SwiftUI iOS 14
How to load wkwebview in widget swiftui ios 14 I am doing something like this (code attached) but it is showing me this image https://www.sendspace.com/file/nw002i (download image from this link) looking forward to your answers by the way i am new…

Faraz Ahmed
- 79
- 10
5
votes
4 answers
How to retrieve widget sizes in app to make a preview of it depending on the device?
I am currently making a widget only application based on SwiftUI that allow users to show some type of informations as time, date etc..
In order to make my application functional I would like to make a preview of the widgets in the app view, also…

Mello
- 53
- 1
- 6
5
votes
1 answer
How can I check whether my shared code is running in a WidgetKit widget or full app?
I'm working on a new iOS app with with widgets. Written in SwiftUI.
Most of my code is shared between the Widget target and the App target, but there are some minor style changes I want to make between the two targets.
Is there a way to check…

Aej11
- 57
- 6