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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let package = Package(
resources: [
.copy("../Sources/PrivacyInfo.xcprivacy")
],
swiftSettings: [visionOSSetting]),
swiftSettings: [.define("CUSTOMER_CENTER_ENABLED"), visionOSSetting]),
.target(name: "RevenueCat_CustomEntitlementComputation",
path: "CustomEntitlementComputation",
exclude: ["Info.plist", "LocalReceiptParsing/ReceiptParser-only-files"],
Expand All @@ -75,7 +75,8 @@ let package = Package(
// Note: these have to match the values in RevenueCatUI.podspec
.copy("Resources/background.jpg"),
.process("Resources/icons.xcassets")
]),
],
swiftSettings: [.define("CUSTOMER_CENTER_ENABLED")]),
.testTarget(name: "RevenueCatUITests",
dependencies: [
"RevenueCatUI",
Expand Down
1 change: 1 addition & 0 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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

SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//
// Created by Cesar de la Vega on 18/7/24.

#if CUSTOMER_CENTER_ENABLED

import Foundation
Comment on lines +14 to 16
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.

import RevenueCat

Expand All @@ -30,3 +32,5 @@ protocol CustomerCenterPurchasesType: Sendable {
product: StoreProduct) async throws -> PromotionalOffer

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 12/6/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand All @@ -35,3 +37,5 @@ protocol ManageSubscriptionsPurchaseType: Sendable {
func beginRefundRequest(forProduct productID: String) async throws -> RefundRequestStatus

}

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/ColorFromAppearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//
// Created by Cesar de la Vega on 30/7/24.

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat
import SwiftUI
Expand All @@ -20,3 +22,5 @@ func color(from colorInformation: CustomerCenterConfigData.Appearance.ColorInfor
for colorScheme: ColorScheme) -> Color? {
return colorScheme == .dark ? colorInformation.dark?.underlyingColor : colorInformation.light?.underlyingColor
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//
// Created by Cesar de la Vega on 17/7/24.

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand All @@ -33,3 +35,5 @@ extension CustomerInfo {
}

}

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/Data/CustomerCenterAction.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if CUSTOMER_CENTER_ENABLED

import RevenueCat

/// Typealias for handler for Customer center actions
Expand All @@ -20,3 +22,5 @@ public enum CustomerCenterAction {
case refundRequestCompleted(_ refundRequestStatus: RefundRequestStatus)

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 28/5/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand Down Expand Up @@ -130,3 +132,5 @@ enum CustomerCenterConfigTestData {
)

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//
// Created by Cesar de la Vega on 19/7/24.

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat
import SwiftUI
Expand Down Expand Up @@ -71,3 +73,5 @@ extension EnvironmentValues {
}

}

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/Data/CustomerCenterError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 29/5/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation

/// Error produced when displaying the customer center.
Expand Down Expand Up @@ -44,3 +46,5 @@ extension CustomerCenterError: CustomNSError {
}

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//
// Created by Cesar de la Vega on 18/7/24.

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand All @@ -35,3 +37,5 @@ final class CustomerCenterPurchases: CustomerCenterPurchasesType {
}

}

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/Data/FeedbackSurveyData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 14/6/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand All @@ -36,3 +38,5 @@ class FeedbackSurveyData: ObservableObject {
}

#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//
// Created by Cesar de la Vega on 18/7/24.

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand Down Expand Up @@ -72,3 +74,5 @@ class LoadPromotionalOfferUseCase: LoadPromotionalOfferUseCaseType {
}

#endif

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/Data/PromotionalOfferData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//
// Created by Cesar de la Vega on 17/7/24.

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand All @@ -22,3 +24,5 @@ struct PromotionalOfferData: Identifiable {
let promoOfferDetails: CustomerCenterConfigData.HelpPath.PromotionalOffer

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 28/5/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation

struct SubscriptionInformation {
Expand Down Expand Up @@ -44,3 +46,5 @@ struct SubscriptionInformation {
}

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 28/5/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat
import SwiftUI
Expand Down Expand Up @@ -58,3 +60,5 @@ struct ManageSubscriptionsButtonStyle_Previews: PreviewProvider {
}

#endif

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/URLUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 28/5/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import SwiftUI

Expand Down Expand Up @@ -42,3 +44,5 @@ enum URLUtilities {
#endif

}

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/View+PresentCustomerCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//
// Created by Toni Rico Diez on 2024-07-15.

#if CUSTOMER_CENTER_ENABLED

import RevenueCat
import SwiftUI

Expand Down Expand Up @@ -130,3 +132,5 @@ private struct PresentingCustomerCenterModifier: ViewModifier {
}

#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 27/5/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand Down Expand Up @@ -133,3 +135,5 @@ import RevenueCat
}

#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 11/6/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation

enum CustomerCenterViewState: Equatable {
Expand All @@ -35,3 +37,5 @@ enum CustomerCenterViewState: Equatable {
}

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 17/6/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand Down Expand Up @@ -74,3 +76,5 @@ class FeedbackSurveyViewModel: ObservableObject {
}

#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 27/5/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand Down Expand Up @@ -246,3 +248,5 @@ private extension SubscriptionPeriod {
}

#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 17/6/24.
//

#if CUSTOMER_CENTER_ENABLED

import Foundation
import RevenueCat

Expand Down Expand Up @@ -74,3 +76,5 @@ class PromotionalOfferViewModel: ObservableObject {
}

#endif

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/Views/CustomerCenterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Andrés Boedo on 5/3/24.
//

#if CUSTOMER_CENTER_ENABLED

import RevenueCat
import SwiftUI

Expand Down Expand Up @@ -122,3 +124,5 @@ struct CustomerCenterView_Previews: PreviewProvider {
#endif

#endif

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/Views/FeedbackSurveyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Cesar de la Vega on 12/6/24.
//

#if CUSTOMER_CENTER_ENABLED

import RevenueCat
import SwiftUI

Expand Down Expand Up @@ -118,3 +120,5 @@ extension FeedbackSurveyButtonsView {
}

#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Andrés Boedo on 5/3/24.
//

#if CUSTOMER_CENTER_ENABLED

import RevenueCat
import SwiftUI

Expand Down Expand Up @@ -357,3 +359,5 @@ struct ManageSubscriptionsView_Previews: PreviewProvider {
#endif

#endif

#endif
4 changes: 4 additions & 0 deletions RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Andrés Boedo on 5/3/24.
//

#if CUSTOMER_CENTER_ENABLED

import RevenueCat
import SwiftUI

Expand Down Expand Up @@ -99,3 +101,5 @@ struct NoSubscriptionsView_Previews: PreviewProvider {
#endif

#endif

#endif
Loading