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

Create separate SPM library to enable custom entitlement computation #2440

Merged
merged 6 commits into from
Apr 25, 2023

Conversation

NachoSoto
Copy link
Contributor

@NachoSoto NachoSoto commented Apr 25, 2023

Fixes SDK-3084

screenshot_2023-04-25_at_10 02 44_480

Changes:

  • Added new ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION compile time flag
  • Hidden configureInCustomEntitlementsModeWithApiKey behind ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION
  • Added new RevenueCat_CustomEntitlementComputation SPM target and library
  • Added CircleCI job for swift build --target RevenueCat_CustomEntitlementComputation
  • Added new SPMCustomEntitlementComputationInstallation using the new configureInCustomEntitlementsComputationMode
  • Added CircleCI job for SPMCustomEntitlementComputationInstallation
  • Added FrameworkDisambiguation.swift to avoid using RevenueCat. disambiguation for files that
  • Changed API testers to only use the new methods if ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION is defined
  • Updated DangerousSettings to not expose customEntitlementComputation publicly. The only way to use that now with public API is through Purchases.configureInCustomEntitlementsModeWithApiKey
  • Updated sample app to use new library

@NachoSoto NachoSoto added the pr:feat A new feature label Apr 25, 2023
@NachoSoto NachoSoto requested a review from a team April 25, 2023 17:51
@@ -0,0 +1 @@
Sources
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This symlink is necessary because SPM requires independent source directories. It's the same workaround we used for ReceiptParser.

@@ -108,7 +108,6 @@ Most features require configuring the SDK before using it.
- ``Purchases/setOnesignalID(_:)``

### Advanced Configuration
- ``Purchases/configureInCustomEntitlementsComputationMode(apiKey:appUserID:)``
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to go away because the main framework no longer exposes this.


import RevenueCat_CustomEntitlementComputation

class InstallationTests: XCTestCase {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I solved the testability issue by having new installation tests that use the new API through the new SPM 🎉

}

func testCanSwitchUser() throws {
Purchases.shared.switchUser(to: "new_user_ID")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't compile yet until #2437 is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works now cc @tonidero

@@ -168,6 +168,24 @@ commands:
working_directory: << parameters.directory >>
when: always

scan:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed this because the other jobs also archive, which we don't ned for the new job.

Comment on lines +40 to +43
.target(name: "RevenueCat_CustomEntitlementComputation",
path: "CustomEntitlementComputation",
exclude: ["Info.plist", "LocalReceiptParsing/ReceiptParser-only-files"],
swiftSettings: [.define("ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION")]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR and no need to fix it here, but mentioning before I forget again:
I noticed this today when playing around with a solution:
this file is only meant for receiptParser, but it's not in the folder. It is only marked for target membership in ReceiptParser, though, so we have a disconnect there
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah we should move that.

Comment on lines +76 to +77
/// - Note: this is `internal` only so the only `public` way to enable `customEntitlementComputation`
/// is through ``Purchases/configureInCustomEntitlementsComputationMode(apiKey:appUserID:)``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice

Comment on lines 1080 to 1082
#endif

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be great to disable everything else (other than this method and switchUser) for this mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, you mean the other configure methods, logIn, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #2442

Comment on lines +15 to +21
Purpose: this file is needed because several parts of the SDK need to explicitily reference a type or value
from the `RevenueCat` target. However, we expose 2 variants of the framework from SPM:
`RevenueCat` and `RevenueCat_CustomEntitlementComputation` (see `Package.swift`).
Because of that, we can't simply do `RevenueCat.ErrorCode` for example, since the other variant
would need `RevenueCat_CustomEntitlementComputation.ErrorCode`.

To handle that, this exposes those types explicitly so they work regardless of the name of the framework.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:chefskiss: on the explanation

@@ -0,0 +1,267 @@
fastlane documentation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably don't need all the fastlane stuff since we can access through the root fastfile right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NachoSoto
Copy link
Contributor Author

I'm gonna update the new test app to use the new SPM.

Base automatically changed from andy/sdk-3068-dangeroussetting-that-disables_rebased to main April 25, 2023 20:21
Fixes SDK-3084

- Added new `ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION` compile time flag
- Hidden `configureInCustomEntitlementsModeWithApiKey` behind `ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION`
- Added new `RevenueCat_CustomEntitlementComputation` SPM target and library
- Added CircleCI job for `swift build --target RevenueCat_CustomEntitlementComputation`
- Added new `SPMCustomEntitlementComputationInstallation` using the new `configureInCustomEntitlementsComputationMode`
- Added CircleCI job for `SPMCustomEntitlementComputationInstallation`
- Added `FrameworkDisambiguation.swift` to avoid using `RevenueCat.` disambiguation for files that
- Changed API testers to only use the new methods if `ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION` is defined
- Updated `DangerousSettings` to not expose `customEntitlementComputation` publicly. The only way to use that now with `public` API is through `Purchases.configureInCustomEntitlementsModeWithApiKey`
@NachoSoto
Copy link
Contributor Author

Holding on this until we figure out if we want to do this with SPM and/or CP.

@NachoSoto
Copy link
Contributor Author

This is ready to be merged if we're good with SPM.

@NachoSoto NachoSoto enabled auto-merge (squash) April 25, 2023 22:07
@NachoSoto NachoSoto merged commit 64c8638 into main Apr 25, 2023
@NachoSoto NachoSoto deleted the spm-custom-entitlements branch April 25, 2023 22:12
NachoSoto added a commit that referenced this pull request Apr 26, 2023
#2440)

Fixes SDK-3084

![screenshot_2023-04-25_at_10 02
44_480](https://user-images.githubusercontent.com/685609/234360670-bd2628a1-0684-490d-a9eb-33846a60f72a.png)

- Added new `ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION` compile time flag
- Hidden `configureInCustomEntitlementsModeWithApiKey` behind
`ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION`
- Added new `RevenueCat_CustomEntitlementComputation` SPM target and
library
- Added CircleCI job for `swift build --target
RevenueCat_CustomEntitlementComputation`
- Added new `SPMCustomEntitlementComputationInstallation` using the new
`configureInCustomEntitlementsComputationMode`
- Added CircleCI job for `SPMCustomEntitlementComputationInstallation`
- Added `FrameworkDisambiguation.swift` to avoid using `RevenueCat.`
disambiguation for files that
- Changed API testers to only use the new methods if
`ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION` is defined
- Updated `DangerousSettings` to not expose
`customEntitlementComputation` publicly. The only way to use that now
with `public` API is through
`Purchases.configureInCustomEntitlementsModeWithApiKey`
- Updated sample app to use new library
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:feat A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants