Use for WidgetKit introduced in iOS 14 and macOS Catalyst 14
Questions tagged [widgetkit]
520 questions
0
votes
1 answer
Parsing RSS XML in WidgetView Extension of iOS 14
I have an XMLParser set up in Swift in my app, and want to be able to within the widget extension, parse the RSS feed, and return that data in the widget. However, I'm having some issues getting the two Swift files to talk to each other. In the…

user717452
- 33
- 14
- 73
- 149
0
votes
1 answer
NSFetchRequest returns wrong value of .count
In my app which uses SwiftUI for interface I have a button that performs an action:
func getBooksCountNumber() -> Int {
var countResult = 0
let booksFetch = NSFetchRequest(entityName: "Book")
do {
let…

Igor R.
- 399
- 4
- 23
0
votes
2 answers
Add an iOS 14 widget in project with compatibility with old iOS
I want to add an iOS 14 widget in my existing project. But I get compile errors is only available in iOS 14.0 or newer. My widget target deployment target is set to iOS 14. Main app and the whole project deployment target is lower – 12.2. The…

Valentin Shamardin
- 3,569
- 4
- 34
- 51
0
votes
0 answers
CoreData with CloudKit in WidgetKit not working
In my app, I have an NSPersistentCloudKitContainer set up in the following way:
let container: NSPersistentCloudKitContainer
init() {
self.container = NSPersistentCloudKitContainer(name: "Model")
…

Richard Robinson
- 867
- 1
- 11
- 38
0
votes
1 answer
Overlay text on Image SwiftUI and WidgetKit
I'm currently creating a widget for my new iOS 14 app and I encountered a weird problem when I'm trying to add and Overlay with Text on top of my Image. The overlay is correctly working on a blank SwiftUI project but it's not working on the…

Pietro Messineo
- 777
- 8
- 28
0
votes
1 answer
Why does siri pop up when testing new iOS 14 widget?
Like the title says, I'm testing widgets locally on a simulator. I have xcode 12, seed 6. On an iPhone 8 simulator.
Upon a fresh install, prior to the widget being installed on the home screen, Siri pops up despite me not having intentionally…

Jay
- 2,591
- 1
- 16
- 28
0
votes
1 answer
Align Images with same size and aspect ratio fill in SwiftUI
I'm using SwiftUI to create a Widget and I'm struggling with something that is pretty simple and straightforward in Swift.
I have 2 images that are next to each other and I want them with the exact same size with aspect ratio fill but without…

Joan Cardona
- 3,463
- 2
- 25
- 43
0
votes
1 answer
iOS WidgetKit - Widget Preview Screen Not Updating on updating the Placeholder View
I am using XCode 12 beta 2 on iOS 14 Simulator & am trying to update the Widget Preview Screen (i.e. the screen which appears when we try to add a new widget) from the Placeholder View
struct PlaceholderView : View {
var body: some View {
…

Abhishek Bedi
- 5,205
- 2
- 36
- 62
0
votes
1 answer
WidgetKit won't request a new timeline at the end
When I run the code snippet below, WidgetKit is supposed to request a new timeline at the end of each minute according to the Apple's documentation.
Code Block
let currentDate = Date()
let futureDate = Calendar.current.date(byAdding: .minute,…

amone
- 3,712
- 10
- 36
- 53
-1
votes
0 answers
Cannot see my widget in Widget Gallery (macOS)
I used a swift package which contains a XCFramework inside it in my widget target. It’s working fine on iOS, and macOS Widget Simulator.
But when I open widget gallery on macOS, I can’t find my widget.
I tried to run my widget directly inside…

LiYanan2004
- 41
- 5
-1
votes
1 answer
Is there a way to call an API within the Timeline Provider?
I am trying to make an iOS widget which shows the recent news posted on a Microsoft Sharepoint Site. I want to call GraphAPI every few hours, so that I can get new posts and refresh the widget.
However, since GraphAPI requires an access token, I…

Gura
- 5
- 2
-1
votes
1 answer
Display lottie animation in iOS WidgetKit
I want to show lottie animation in iOS WidgetKit. I use this project https://github.com/airbnb/lottie-ios. It works well in APP. But same code not work in WidgetKit.
The code in APP is as bellow, which works well in APP:
struct widgetTestyView :…

mars
- 109
- 5
- 21
-1
votes
1 answer
How to stop live activity time from rounding down
I have a live activity with a timer and when isLuminanceReduced is true, the timer rounds down.
How do I get my live activity to stay at 40:00 when the timer is paused at 40:00 instead of 39:--
struct TimerTextView: View {
let range =…

sfung3
- 2,227
- 1
- 9
- 30
-1
votes
1 answer
SwiftUI Text.DateStyle Timer change format
I am trying to create a Widget with SwiftUI, and I want to use the ".timer" style from Text to show a countdown, but the result of the Text(entry.date, style: .timer) is 1.34.23.
I want to use : instead of . as separator.
And is it possible to add a…

Kaiison
- 41
- 4
-1
votes
2 answers
What iOS api is used to put a colourful countdown timer in the Lock Screen notification area?
When you have an active timer in the Apple clock app, it displays the countdown as a colourful interactive widget in the notifications area of the Lock Screen.
I know that it used to be the case that Apple's clock app used a private API to put a…

Bernie Sumption
- 444
- 6
- 11