WidgetKit app in Obj C Project

Im interested in adding a Widget into my Mix Obj C / Swift project and i believe i can, i understand WidgetKit is SwiftUI but as its an extension i can add it to my ObjC project. My question is (similar to WCSession), is WidgetCenter the framework used in the Main App, to Reload the widget etc. And if so how would you go about doing that in an ObjC project, or how do you reload widget for your main ObjC/Swfit App? Thanks!

Replies

You are totally correct that you can support WidgetKit in an Objc app because the extension is completely separate. WidgetCenter, specifically, is an API that you use from your main app to invalidate your extension's timeline. It does not have an Objc API. Instead, you need to add Swift code to your project and follow the steps here..
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 have the same doubts about how to call WidgetCenter in objc projects.
@grwilde  do you have more information how you imported you data from swift to swiftui? I have the same problem. I just need to pass some variables.