Widgets not displaying data when running on iOS 18

When I build my app on Xcode 16 and run it in an iOS 18 simulator The data downloaded in the app will not get to the widget. Same behaviour happens when running on a physical device. If I run the app in a iOS 17.5 simulator the widget gets and displays the data correctly.

is there a setting that I need to change that I’ve missed?

The app works perfectly on iOS 18 with a build built in Xcode 15.4

Can you explain in more detail how you are sharing the data between your app and widgets?

Rico

WWDR - DTS - Software Engineer

I use a specific suiteName to send the data through UserDefaults, with my own key.

private func sendWeatherDataToWidget(input: CurrentDataConverted) {
        let widgetData: WidgetWeatherData = WidgetWeatherData(theTemp: input.currentTemp,
                                                              theMax: input.dailyMaxTemp,
                                                              theMin: input.dailyMinTemp,
                                                              theTime: input.time,
                                                              theTempUnits: input.temperatureUnits,
                                                              theLocation: input.location)
        let tempData = try! JSONEncoder().encode(widgetData)
        UserDefaults(suiteName: "group.com.emkubed.Weewx-Weather")!.set(tempData,forKey: "Weewx-Weather")
        
        WidgetCenter.shared.reloadTimelines(ofKind: "com.emkubed.Weewx-Weather")
        logger.debug("Sent data to Widget - hopefully")
    }

I am having the same problem. My widgets stopped working with Xcode 16 and iOS 18 both on the simulator and on actual devices. I also am using UserDefaults to pass data, but the data is not passed but it was under previous Xcode versions. The app will still launch from the widget, but the widget data is missing.

I'm having the same issue too. I'm using App Group to share a file containing data between the main app and the widgets. It used to work just fine, but now, the Widget get a permission denied error when trying to access the file. I tried to rename the app group on both side, reset cache & derived data, etc... it just doesn't work.
I also tried with the default Apple template and it doesn't work either.

Quick update. In the other apps I’ve written that use exactly the same process to update their widgets, they are updating. They only have a Lock Screen widget and not normal ones. I’m not sure if that difference is enough to cause it not to update at all.

Widgets not displaying data when running on iOS 18
 
 
Q