Skip to main content
Question

Problem with mixed Objective C/Swift


Forum|alt.badge.img+4
  • New Member
  • 3 replies

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?

This post has been closed for comments

3 replies

joan-cardona
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 313 replies
  • January 23, 2025

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!

Forum|alt.badge.img+4
  • Author
  • New Member
  • 3 replies
  • January 23, 2025

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...).


joan-cardona
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 313 replies
  • January 29, 2025

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,


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings