Post

Replies

Boosts

Views

Activity

Reply to Swift6 race warning
Thanks for taking a look. I tried some more things and it looks like it's a misleading compiler error, maybe nothing to do with the path variable at all even though the compiler says it is. I took the path variable out of the function temporarily, then it gave another error: "Task or actor isolated value cannot be sent; this is an error in the Swift 6 language mode". The containing class is marked as @Observable, so I'm assuming really it is complaining that "self" is getting pulled into the Task which can cause race conditions even though the compiler error does not say that. I added the Sendable protocol to the container class and the warning went away. Thanks for taking the time to look into it. Side note: Swift6 makes writing code miserable, it's so broken still, good idea poor execution.
Jan ’25
Reply to [iOS 18] Colors from asset catalog render as pure white on tinted widgets
When you select tinted your widget is rendered in accented mode. Accented mode splits the UI elements into two groups, the default group and the accented group. Basically you only get two colors the accented group will get the tinted color the other group is white. You swap your UI elements between the groups using the widgetAccentable modifier: https://developer.apple.com/documentation/swiftui/view/widgetaccentable(_:) You can still apply an opacity to the UI elements if you want. If you want them to be the original color then you can use the https://developer.apple.com/documentation/widgetkit/widgetaccentedrenderingmode property but that only applies to Image elements.
Sep ’24
Reply to Widgets not working in iOS 17.2
We were also having this issue. It was recommended to make sure that any images you have aren't too big, ideally somewhere around the size of the widget dimensions, that should help fix this problem. Reducing the size of the images we were using as backgrounds to our widgets seems to have helped us.
Jan ’24
Reply to WeatherKit REST API access
The WeatherKit option is un the Capabilities tab not App Services. You also need to register a WeatherKit key in the top level Keys section in the developer site. Once you have completed both of those step, this question has information on how to call the REST API using a JWT: https://developer.apple.com/forums/thread/707418
Jun ’22
Reply to Can't test subscription upgrade/downgrade. iOS doesn't use the sandbox account
Unfortunately, entering my real apple ID/password does not work. It show success but the upgrade/downgrade never occurs the UI still shows the original subscription level. Signing out of the production AppleID and only having the sandbox tester on the device doesn't work either. In that scenario the password box is displayed but with an empty username in the dialog, entering the sandbox password just fails. I'm confused how people are successfully testing these scenarios :/
Mar ’21
Reply to Widget getSnapshot method won't call for second time
There is no guarantee that getSnapshot will be called each time the galley is opened, the OS might cache previous results as you've seen. In the case the user has never logged in to the app and adds the widget, so their is no previous cached data in your getSnapshot call you could check the auth status of your app and if the user is logged out: Show a "Logged out" UI in the widget Show some canned data to fill out your widget with example data (to make it look good in the gallery). Then once the user logs in via the app you can get the widget to refresh its UI by calling: https://developer.apple.com/documentation/widgetkit/widgetcenter/reloadalltimelines() For the other case where you don't want cached data in the gallery once the user logs out, you could try calling reloadAllTimelines() when the user logs out in the app and see if that causes the snapshot to be updated.
Sep ’20
Reply to Removing a widget from project
If you set the supportedFamilies modifier on the WidgetConfiguration to [] then the widget no longer shows in the widget gallery. That might be an option. e.g. public var body: some WidgetConfiguration {     StaticConfiguration(       kind: kind,       provider: Provider()     ) { entry in       widget_mainEntryView(entry: entry)     }     .configurationDisplayName("Foo")     .description("Foo")     .supportedFamilies([])   }
Aug ’20
Reply to can I get current location in widgetKit
You need to make sure you have both these plist values set in your widgets Info.plist file: <key>NSWidgetWantsLocation</key> <true/> <key>NSLocationUsageDescription</key> <string>Put some text here</string> Then when you open the widget gallery, looks like from beta5 onwards iOS will show a prompt asking you to allow/deny location permissions to the widget. The next important thing is that inside getTimeline() if you are creating an instance of CLLocationManager you must keep a reference to it past the end of the getTimeline call otherwise no updates will happen on the delegate. In my case I just created a wrapper class that the widget stores as a property then I setup the CLLocationManager instance on the first run of getTimeline and assign it to a field in the wrapper class. At least this worked for me :)
Aug ’20