Creating a mock CustomerInfo to use for a Swift UI preview?

  • 7 November 2021
  • 2 replies

Badge +2

Hi All,

I’m trying to use Swift UI previews in order to develop my subscription screen, and I want to pass through the `CustomerInfo` object I have stored in my view model to do that (similar to the MagicWeather test app)

But unfortunately, the CustomerInfo() initializer is not accessible outside the module - if I try to create example info, I get the message “'CustomerInfo' initializer is inaccessible due to 'internal' protection level”

This similarly prevents me using a convenience init (since I can’t call the original init) which is what happens in the internal Revenue Cat tests (as far as I can tel)

Has anyone got this working, or does everyone just develop on-device?



2 replies

Userlevel 4
Badge +8

Hey @nikz!

Since we don’t publicly expose those inits, I don’t think this is currently possible with the SDK. I do think it would be a valuable feature especially when building SwiftUI apps, so I’ll share this with the SDK team and see if we can find a way to get this supported at some point in the future.

I’ll leave the thread open for anyone else to comment in case someone else has any ideas!

I ran into this too but beyond just having some ugly conditional text in my UI itself as placeholders I haven’t had a chance to dig into this much.

my next plan of attack is to reorg my code to be more MVVM so I can find a spot to inject/clean up variables in the view model and reference those in my UI, instead of accessing the RC framework variables directly.