Hey @owenzhao!
I’m not very familiar with SwiftUI Preview, but I’m not sure it supports calling AppDelegate initialization code. Since the preview is meant to test/demo your UI, your best bet is likely to run the project on your device so our SDK can make the necessary API calls and go through the proper app lifecycle (as well as making purchases, etc.).
I’ll leave this post open in case anyone else has some context they can add here!
I believe you can do this right within the preview section @owenzhao
i.e.
init(){ Purchases.configure(withAPIKey: "api key") }
Instead of having to provide this for each screen however I recommend a class for RC which sets this all up. In my preview class for example I just do something like this:
SubscriptionView()
.environmentObject(SubscriptionManager())
The init of the manager handles the Purchases.configure
It also helps to run the preview in live mode so that the callback for offerings is rendered as well.