Skip to content

Commit

Permalink
Enable Paywall Tester to build with Paywalls V2 (#4487)
Browse files Browse the repository at this point in the history
* DON'T COMMIT THIS

* Maybe this

* Maybe this

* This will do it

* This should do it

* Oops, remove one more thing

* One more time

* One more time

* Maybe this

* Ths is it
  • Loading branch information
joshdholtz authored Nov 13, 2024
1 parent d23fa7f commit 60e3bca
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ var additionalCompilerFlags: [PackageDescription.SwiftSetting] = {
?? []
}()

var ciCompilerFlags: [PackageDescription.SwiftSetting] = [
// REPLACE_WITH_DEFINES_HERE
]

// Only add DocC Plugin when building docs, so that clients of this library won't
// unnecessarily also get the DocC Plugin
let environmentVariables = ProcessInfo.processInfo.environment
Expand Down Expand Up @@ -75,7 +79,7 @@ let package = Package(
resources: [
.copy("../Sources/PrivacyInfo.xcprivacy")
],
swiftSettings: [visionOSSetting] + additionalCompilerFlags),
swiftSettings: [visionOSSetting] + ciCompilerFlags + additionalCompilerFlags),
.target(name: "RevenueCat_CustomEntitlementComputation",
path: "CustomEntitlementComputation",
exclude: ["Info.plist", "LocalReceiptParsing/ReceiptParser-only-files"],
Expand All @@ -85,7 +89,7 @@ let package = Package(
swiftSettings: [
.define("ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION"),
visionOSSetting
] + additionalCompilerFlags),
] + ciCompilerFlags + additionalCompilerFlags),
// Receipt Parser
.target(name: "ReceiptParser",
path: "LocalReceiptParsing"),
Expand All @@ -101,7 +105,7 @@ let package = Package(
.copy("Resources/background.jpg"),
.process("Resources/icons.xcassets")
],
swiftSettings: additionalCompilerFlags),
swiftSettings: ciCompilerFlags + additionalCompilerFlags),
.testTarget(name: "RevenueCatUITests",
dependencies: [
"RevenueCatUI",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ struct APIKeyDashboardList: View {
Text(self.offering.serverDescription)
Spacer()
#if PAYWALL_COMPONENTS
Image(systemName: "exclamationmark.circle.fill")
.foregroundStyle(Color.red)
.hidden(if: self.offering.paywallComponentsData?.errorInfo?.isEmpty ?? true)
if let errorInfo = self.offering.paywallComponentsData?.errorInfo, !errorInfo.isEmpty {
Image(systemName: "exclamationmark.circle.fill")
.foregroundStyle(Color.red)
}
#endif
}
}
Expand All @@ -199,17 +200,13 @@ extension APIKeyDashboardList.Template: CustomStringConvertible {

var description: String {
if let name = self.name {
#if DEBUG
if name == "components" {
return "V2"
} else if let template = PaywallTemplate(rawValue: name) {
return template.name
} else {
return "Unrecognized template"
}
#else
return name
#endif
} else {
return "No paywall"
}
Expand Down
12 changes: 10 additions & 2 deletions Tests/TestingApps/PaywallsTester/ci_scripts/ci_pre_xcodebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ echo "Replacing API keys on PaywallsTester"
file="$SCRIPT_DIR/../PaywallsTester/Config/ConfigItem.swift"
sed -i '' 's/static var apiKey: String { "" }/static var apiKey: String { "'"$REVENUECAT_XCODE_CLOUD_RC_APP_API_KEY"'" }/' $file

echo "Enabling PAYWALL_COMPONENTS compiler flag"
echo "SWIFT_ACTIVE_COMPILATION_CONDITIONS = \$(inherited) PAYWALL_COMPONENTS" > "$SCRIPT_DIR/../Local.xcconfig"
# This allow Local.xcconfig to be found by Xcode
xcconfig_file="$(cd "$SCRIPT_DIR/../../../../" && pwd)/Local.xcconfig"

echo "Enabling PAYWALL_COMPONENTS compiler flag in $xcconfig_file"
echo "SWIFT_ACTIVE_COMPILATION_CONDITIONS = \$(inherited) PAYWALL_COMPONENTS" > "$xcconfig_file"

# Update Package.swift with PAYWALL_COMPONENTS define
package_file="$(cd "$SCRIPT_DIR/../../../../" && pwd)/Package.swift"
sed -i '' 's/\/\/ REPLACE_WITH_DEFINES_HERE/.define("PAYWALL_COMPONENTS")/' "$package_file"

0 comments on commit 60e3bca

Please sign in to comment.