-
Notifications
You must be signed in to change notification settings - Fork 316
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
Conversation
@@ -0,0 +1 @@ | |||
Sources |
There was a problem hiding this comment.
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:)`` |
There was a problem hiding this comment.
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.
7e2bd6c
to
ae1f190
Compare
|
||
import RevenueCat_CustomEntitlementComputation | ||
|
||
class InstallationTests: XCTestCase { |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
ae1f190
to
8c844e0
Compare
587c971
to
53e3f08
Compare
@@ -168,6 +168,24 @@ commands: | |||
working_directory: << parameters.directory >> | |||
when: always | |||
|
|||
scan: |
There was a problem hiding this comment.
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.
.target(name: "RevenueCat_CustomEntitlementComputation", | ||
path: "CustomEntitlementComputation", | ||
exclude: ["Info.plist", "LocalReceiptParsing/ReceiptParser-only-files"], | ||
swiftSettings: [.define("ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION")]), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
/// - Note: this is `internal` only so the only `public` way to enable `customEntitlementComputation` | ||
/// is through ``Purchases/configureInCustomEntitlementsComputationMode(apiKey:appUserID:)``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nice
#endif | ||
|
||
/** |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #2442
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was autogenerated, probably because it inherits stuff through the import
: https://github.com/RevenueCat/purchases-ios/blob/53e3f083d635e9365a1f8618f8d63a035e58f0f4/Tests/InstallationTests/SPMCustomEntitlementComputationInstallation/fastlane/Fastfile
I'm gonna update the new test app to use the new SPM. |
53e3f08
to
67beed5
Compare
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`
c96ddc6
to
da51d52
Compare
63c9a6c
to
9c406cd
Compare
Holding on this until we figure out if we want to do this with SPM and/or CP. |
This is ready to be merged if we're good with SPM. |
#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
Fixes SDK-3084
Changes:
ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION
compile time flagconfigureInCustomEntitlementsModeWithApiKey
behindENABLE_CUSTOM_ENTITLEMENT_COMPUTATION
RevenueCat_CustomEntitlementComputation
SPM target and libraryswift build --target RevenueCat_CustomEntitlementComputation
SPMCustomEntitlementComputationInstallation
using the newconfigureInCustomEntitlementsComputationMode
SPMCustomEntitlementComputationInstallation
FrameworkDisambiguation.swift
to avoid usingRevenueCat.
disambiguation for files thatENABLE_CUSTOM_ENTITLEMENT_COMPUTATION
is definedDangerousSettings
to not exposecustomEntitlementComputation
publicly. The only way to use that now withpublic
API is throughPurchases.configureInCustomEntitlementsModeWithApiKey