Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Crash when calling Purchases.configure with error configureWithAPIKey unrecognized selector sent to class #216

Open
9 of 10 tasks
brahyam opened this issue Sep 21, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@brahyam
Copy link

brahyam commented Sep 21, 2024

Describe the bug
A clear and concise description of what the bug is. The more detail you can provide the faster our
team will be able to triage and resolve the issue. Do not remove any of the steps from the
template below. If a step is not applicable to your issue, please leave that step empty.

I'm trying to integrate the KMP SDK into a KMP app (including the Paywall UI). However when calling from KMP

val purchasesConfig = PurchasesConfiguration(apiKey) {
   appUserId = userId
}
Purchases.configure(purchasesConfig)

The iOS app crashes with the error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[RCPurchases configureWithAPIKey:appUserID:purchasesAreCompletedBy:userDefaultsSuiteName:platformFlavor:platformFlavorVersion:storeKitVersion:dangerousSettings:shouldShowInAppMessagesAutomatically:verificationMode:]: unrecognized selector sent to class 0x106566110'
  1. Environment
    1. Platform: iOS
    2. SDK version: 1.0.1+13.2.1
    3. OS version: 17.2
    4. IDE (e.g. Android Studio, Xcode, Fleet): Android Studio , Xcode
    5. IDE version: Android Studio Koala Feature Drop | 2024.1.2, Xcode Version 15.2 (15C500b)
    6. Device and/or emulator/simulator:
      • Device
      • Emulator/simulator
    7. Environment:
      • Closed testing / Sandbox
      • TestFlight
      • Production
    8. How widespread is the issue. Percentage of devices affected. 100%
  2. Debug logs that reproduce the issue
    No logs as the SDK is not able to initialize.
  3. Steps to reproduce, with a description of expected vs. actual behavior
  • Add Purchases.configure(purchasesConfig) to KMP
  • Run the app.
    Expected
    SDK is initialized
    Actual
    App Crashes
  1. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to
    have context, eg. stackoverflow, etc.)
    I added a Pod to link the Hybrid framework as in the docs. This is my Pod.lock
PODS:
  - PurchasesHybridCommon (13.2.1):
    - RevenueCat (= 5.3.3)
  - RevenueCat (5.3.3)

DEPENDENCIES:
  - PurchasesHybridCommon (= 13.2.1)

SPEC REPOS:
  trunk:
    - PurchasesHybridCommon
    - RevenueCat

SPEC CHECKSUMS:
  PurchasesHybridCommon: 7955b21cc5a8be78cea6dcf92f3906f3e5cec972
  RevenueCat: d9e8b1b56bf81483cf8bb902a952a2da8749b964

PODFILE CHECKSUM: 40220c225a9794bced0d516b00d95455a7211622

COCOAPODS: 1.15.2

This is my lib.versions.toml

revenuecat-purchases = "1.0.1+13.2.1"

revenuecat-purchases-core = { module = "com.revenuecat.purchases:purchases-kmp-core", version.ref = "revenuecat-purchases" }
revenuecat-purchases-datetime = { module = "com.revenuecat.purchases:purchases-kmp-datetime", version.ref = "revenuecat-purchases" }
revenuecat-purchases-ui = { module = "com.revenuecat.purchases:purchases-kmp-ui", version.ref = "revenuecat-purchases" }

This is my gradle

kotlin {
...
listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            isStatic = true
            ...
        }
    }

sourceSets {
        commonMain.dependencies {
         ...
        implementation(libs.revenuecat.purchases.core)
        implementation(libs.revenuecat.purchases.datetime)
        implementation(libs.revenuecat.purchases.ui)
        
**Additional context**
KMP app, targeting android and iOS only. using XCframeworks 
other possible relevant versions:
agp = "8.4.1"
kotlin = "2.0.0"
jetbrains-compose = "1.6.10"

@brahyam brahyam added the bug Something isn't working label Sep 21, 2024
@JayShortway
Copy link
Member

JayShortway commented Sep 23, 2024

Hi, thanks for the detailed report! I'm not entirely sure what's going wrong, as everything you shared looks correct.

The "unrecognized selector" error usually points to the linked framework (pod) being different from what the Kotlin code expects.

Some thoughts/questions/leads:

  • Could it be that you had specified the RevenueCat pod first, and specified the PurchasesHybridCommon pod later? If so, did you run pod install --repo-update afterwards? (Can't hurt to run that again, just in case.)
  • When it crashes in Xcode, could you run po 0x106566110 in the lldb command prompt in the bottom right? Note that the memory address (0x106566110) is likely different each time, so make sure you use the actual address reported in the crash.
  • Probably unrelated to the crash, but since you mentioned you'd like to use Paywalls, you'd need to specify the PurchasesHybridCommonUI pod. You can then omit PurchasesHybridCommon. Don't forget to run pod install --repo-update after you made that change.

@brahyam
Copy link
Author

brahyam commented Sep 23, 2024

Thanks @JayShortway will try again and paste the results shortly. Is there a way of achieving this without having to use CocoaPods? I'm not using them in my project and had to include them because of this.

I'm currently using https://github.com/mirzemehdi/KMPRevenueCat which doesnt need me to use Cocoapods and trying to migrate to the official one.

Also FYI the UI library is missing from the official docs installation section and the SDK reference,

@JayShortway
Copy link
Member

Is there a way of achieving this without having to use CocoaPods?

Thanks for this feedback. You're the third one to ask, so it seems we should do something about it. 😄 The PR linked above should make it possible to integrate without CocoaPods.

Also FYI the UI library is missing from the official docs installation section and the SDK reference,

Regarding the Paywall docs, they are separate: https://www.revenuecat.com/docs/tools/paywalls. Regarding the SDK reference, you are right! That should be fixed by #207, meaning they'll get updated with our next release.

@JayShortway
Copy link
Member

Hi @brahyam, you should now be able to integrate PurchasesHybridCommonUI without CocoaPods. Here's the URL to the repo: https://github.com/RevenueCat/purchases-hybrid-common/. Let me know how this works for you!

@adrianegraphene
Copy link

Oh boy, I am so looking forward to this. I only started the CocoaPods integration because of the Paywall, but that has been a lift that has stalled me for a week now. Will see if I can try with the SPM side of things, thank you.

@adrianegraphene
Copy link

adrianegraphene commented Sep 24, 2024

Edit: I guess SPM hasn't picked up the new commit yet. So for now, you can use specify commit
886951d557fe8849dd1944548da1772d88968978
when selecting the package from this URL and it'll work as expected.
https://github.com/RevenueCat/purchases-hybrid-common/

BELOW ISSUES RESOLVED - SEE EDIT ABOVE
FYI @JayShortway I've tried a couple of different ways to add the Repo via Swift Package Manager and cannot get it to resolve. Maybe it's just me? I've tried both
https://github.com/RevenueCat/purchases-hybrid-common/
image

and
https://github.com/RevenueCat/purchases-hybrid-common.git
image

@JayShortway
Copy link
Member

@adrianegraphene Thanks for figuring this out! It's probably because the Package.swift file doesn't exist at the 13.2.1 tag. Will get a new release out so this workaround is no longer needed.

@JayShortway
Copy link
Member

@adrianegraphene @brahyam Just FYI: starting with version 1.1.0+13.3.0 you should be able to integrate PurchasesHybridCommonUI using the 13.3.0 version instead of the commit.

@brahyam
Copy link
Author

brahyam commented Sep 28, 2024

@JayShortway I just tried and I'm still getting the same error as @adrianegraphene (using both urls he mentioned)
Screenshot 2024-09-28 at 13 57 31
I even tried using a commit number but still fails. But I clicked on add anyway and it worked.

Could it be because I still had the regular iOS RC package added?. After adding this one the package sync was failing to I had to remove the iOS one and reset packages cache for it to work.

Would be great if you could update the docs to show this way of adding it without using pods

@JayShortway
Copy link
Member

Hi @brahyam, the docs have just been updated. This section is the one explaining how to integrate PurchasesHybridCommon using Swift Package Manager.

It's indeed likely that your issue was caused by the fact that you still had the regular RevenueCat package added. PurchasesHybridCommon depends on RevenueCat. Maybe the version you added was different from the one PurchasesHybridCommon expects. In any case, the regular RevenueCat package should not be added manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants