Skip to main content

Been using RevenueCat for many years in a mixed Objective C/Swift project and suddenly having problems:

        Purchases.shared.getCustomerInfo { (customerInfo, error) in

            DispatchQueue.main.async {

                if let error = error {

                    let alert = UIAlertController(title: nil, message: error.localizedDescription, preferredStyle: UIAlertController.Style.alert)

                    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))

                    self.present(alert, animated: true, completion: nil)

                } else if let customerInfo = customerInfo {

                    myObjectiveCClass.purchaserInfo = customerInfo

Last line gives the compilation error: Cannot assign value of type 'RevenueCat.CustomerInfo' to type '__ObjC.CustomerInfo'

They are the same type. Here’s the declaration in myObjectiveCClass:

@property (retain, nonatomic) RCCustomerInfo *purchaserInfo;

and show definition on that RCCustomerInfo goes to the definition in the RC API:

@objc(RCCustomerInfo) public final class CustomerInfo: NSObject {

Clearly the same type just with a different Objective C name. What is going on, where is “__ObjC.CustomerInfo” coming from?

Hi ​@MaxC,

Just to clarify, has this happened only by upgrading to another version of the SDK or have you done changes in the code as well?

Would you mind trying to cast RCCustomerInfo?

myObjectiveCClass.purchaserInfo = (RCCustomerInfo *)customerInfo;
This makes it clear to the compiler that you want to use RevenueCat's Objective-C type rather than letting Swift try to figure out the bridging on its own.
Let me know if this helps!

Thanks for coming back to me. It’s been a few days since posting and in that time we’ve had to switch to StoreKit 2 to work around the problem (which was simpler than the RC API even with the need to wrap it for use in Objective C...).


Hi ​@MaxC,

Thank you for your honest feedback - I’ll go ahead and share it with the team. I’m sorry that we could not fix the issue on time.

Best,


Reply