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.
Post
Replies
Boosts
Views
Activity
I also have an Objective C main app and have implemented a SwiftUI widget extension which seems to work fine (I am using UserDefaults to send initial data to the widget, and that is working). However, I would like to update the widget from my main app and am having difficulty accessing WidgetCenter from it to do the update. I am not clear how to add the Swift code into my Objective C main app to do it. I tried the steps outlined in the previous reply without success, so I must be doing something wrong. Any suggestions?
I solved the problem I was having. It turns out I was using an incorrect App Group identification.
I am having the same problem and am unable to pass UserDefaults with the same registered suite name from my main app to my iOS 14 Widget Extension. The UserDefaults (with the same suite name) are working properly in my main Objective C app, but are returning nil in the SwiftUI Widget extension. The UserDefaults AppGroups are included in both targets. I am new to SwiftUI and have probably done something wrong, but I have no clue what the issue may be. Does anyone have any suggestions?