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

Customer Center compilation flag #4149

Conversation

aboedo
Copy link
Member

@aboedo aboedo commented Aug 6, 2024

We have a long-running integration branch for Customer Center, long running integration branches usually get very tricky to merge as time passes on.

This PR attempts to solve it by creating a single custom compiler flag that enables the Customer Center feature.

Here is what the compilation flag looks like:
image

Then all we need to do to integrate into main is to delete that flag. And re-add it for development. Easy peasy.

And when we want to ship Customer Center for real, we just delete all usages of that flag.

If the flag isn't defined, then the code evaluates to false and is simply skipped by the compiler. If it evaluates to true, then the code runs.

@aboedo aboedo requested a review from a team August 6, 2024 20:18
@aboedo aboedo self-assigned this Aug 6, 2024
@RevenueCat-Danger-Bot
Copy link

RevenueCat-Danger-Bot commented Aug 6, 2024

1 Warning
⚠️ This PR increases the size of the repo by more than 100.00 KB (increased by 194.56 KB).

Generated by 🚫 Danger

@aboedo aboedo added the ci label Aug 6, 2024
@@ -6742,6 +6742,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = CUSTOMER_CENTER_ENABLED;
Copy link
Member Author

Choose a reason for hiding this comment

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

in order to merge to main, we just make a new PR that kills this line. And then we bring it back in the integration branch

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that since the flag is only defined for the Xcode project, SPM and CocoaPods builds will already evaluate it to false and skip Customer Center. Carthage won't, however, since it reads from Xcode, so we should remove it to merge into main

Comment on lines +14 to 16
#if CUSTOMER_CENTER_ENABLED

import Foundation
Copy link
Member Author

Choose a reason for hiding this comment

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

okay, I'll admit that it's annoying to have this in 30 files, but it legitimately took me just a couple of mins to add

Copy link
Member Author

Choose a reason for hiding this comment

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

and we'll only need to remove it when we're ready to ship the feature

Copy link
Contributor

Choose a reason for hiding this comment

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

I bet we can probably leave it out in some of these files... But better to be sure 👍

Copy link
Member

Choose a reason for hiding this comment

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

No idea if this is in the realm of possibilities, but would it be possible to have the the flag only around public entry points of the Customer Center feature? E.g. Purchases.loadCustomerCenter(), CustomerCenterView() and the presentCustomerCenter() modifier?

Copy link
Contributor

Choose a reason for hiding this comment

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

While that should be fine for RevenueCat (we would just need the flag for loadCustomerCenter and CustomerCenterConfigData), since CustomerCenterConfigData is used throughout RevenueCatUI, we would need to wrap many files there.

Copy link
Member

Choose a reason for hiding this comment

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

What if.. we only wrap the constructor of CustomerCenterConfigData (or make the constructor public if the flag exists, internal otherwise). We'd be exposing some extra types, but no dev would be able to actually do anything with them because they can't construct anything.
(Just spitballing, lmk if this is dumb.)

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a bunch of internal types inside CustomerCenterConfigData so we would need to wrap a bunch of constructors... It would however, remove the need to wrap the code in RevenueCatUI...

Having said that, we would still be exposing new types which can potentially change, even if they are unusable... So I don't think it's ideal 😓

Copy link
Member

Choose a reason for hiding this comment

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

Hmm yea, not ideal indeed. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I figured we can probably fine tune this a bit. TBH I figured I'd go with the most brainless imaginable approach which is to wrap all the things just because:

  • I'm not that familiar with the implementation so the dumb approach took me 10 mins
  • It's so easy that removing it would also just take 10 mins of brainless work when we're done with it
  • It's all temporary and we hope to kill this stuff in like maybe a month

If you feel that it's still worth the trouble, I'm more than happy to do it, but it might take me a while, so feel free to take it over and carry it through the finish line.

I figured my biggest contribution here would be setting up the skeleton, i.e.: the compilation flag and the usage, feel free to adapt it to whatever is best!

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think you're making very good points. Not worth the extra effort to do fine tuning imo. Also, we don't have a good idea what fine tuning would even look like yet.

@aboedo
Copy link
Member Author

aboedo commented Aug 6, 2024

If you wanna test out the branch, I'd recommend running things as usual once, then removing the flag from the project settings (but keeping it in the code), then running again to verify that that actually removes all of CustomerCenter.

You might need to clean builds if Xcode doesn't realize that the flag affects more than one project automatically.

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Love this! And yeah, with this we can merge the integration branch back to main much more easily 👍

Comment on lines +14 to 16
#if CUSTOMER_CENTER_ENABLED

import Foundation
Copy link
Contributor

Choose a reason for hiding this comment

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

I bet we can probably leave it out in some of these files... But better to be sure 👍

@tonidero tonidero added build and removed ci labels Aug 8, 2024
@tonidero tonidero merged commit 92db864 into integration/customer_support_workflow Aug 8, 2024
5 checks passed
@tonidero tonidero deleted the andy/customer_center_compilation_flag branch August 8, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants