Skip to content

Commit

Permalink
[Paywalls V2] Remove/replace PAYWALL_COMPONENTS compiler flag and f…
Browse files Browse the repository at this point in the history
…ix OS/platform compile issues (#4727)

* We can't just remove PAYWALL_COMPONENT because we don't support macos and tv and things were failing

* Move PartialComponent outside of PaywallComponent extension

* Fix some lint errors

* Wrong thing

* Undid things i shouldn't have done

* Removed more

* Added comment

* Removed/fix some places for the check thingies

* RevenueCat module compiles on all the things

* RevenueCatUI compiles in all the platforms now

* Make all the things compile again

* Make work for visionOS

* Fix some platform and xcode version issues

* Fix failing spm ios 15 test

* Undo circleci changes

* Replace smooth with easeInOut

* Only run the thing i want

* Attempt to remove circular

* Explicit returns

* Does this pass

* This is it

* Swift 5.9 for this

* All tests again

* Undid public testing processor stuff

* Undo this too

* Swift compiler check out pill style circular

* Fixes from PR review

* Fix compile for mac
  • Loading branch information
joshdholtz authored Jan 29, 2025
1 parent df8dc08 commit 3d86d7d
Show file tree
Hide file tree
Showing 106 changed files with 132 additions and 359 deletions.
2 changes: 0 additions & 2 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@
4D322E3A2B7E7B570004AF53 /* PurchasesOrchestratorSK1Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D322E392B7E7B570004AF53 /* PurchasesOrchestratorSK1Tests.swift */; };
4D322E3C2B7E7E250004AF53 /* PurchasesOrchestratorCommonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D322E3B2B7E7E250004AF53 /* PurchasesOrchestratorCommonTests.swift */; };
4D3BA4CC2D37D15E00668AFC /* PaywallTimelineComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D3BA4CB2D37D15E00668AFC /* PaywallTimelineComponent.swift */; };
4D3BA4CD2D37D15E00668AFC /* PaywallTimelineComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D3BA4CB2D37D15E00668AFC /* PaywallTimelineComponent.swift */; };
4D3BA5882D432E5900668AFC /* Fill.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D3BA5872D432E5700668AFC /* Fill.swift */; };
4D3BA5B22D47AB4400668AFC /* TimelineComponentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D3BA5AF2D47AB4400668AFC /* TimelineComponentView.swift */; };
4D3BA5B32D47AB4400668AFC /* TimelineComponentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D3BA5B02D47AB4400668AFC /* TimelineComponentViewModel.swift */; };
Expand Down Expand Up @@ -6725,7 +6724,6 @@
88A543E12C37A4820039C6A5 /* TemplateView+MultiTier.swift in Sources */,
3523048A2D0A0F30003971A4 /* ErrorView.swift in Sources */,
887A60B72C1D037000E1A461 /* WatchTemplateView.swift in Sources */,
4D3BA4CD2D37D15E00668AFC /* PaywallTimelineComponent.swift in Sources */,
887A60722C1D037000E1A461 /* PaywallViewMode+Extensions.swift in Sources */,
887A60C32C1D037000E1A461 /* FooterView.swift in Sources */,
2C7457212CE702BB004ACE52 /* PackageContext.swift in Sources */,
Expand Down
30 changes: 0 additions & 30 deletions RevenueCatUI/PaywallView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public struct PaywallView: View {
countries: offering.paywall?.zeroDecimalPlaceCountries
)

#if PAYWALL_COMPONENTS
if let paywallComponents = offering.paywallComponents {

// For fallback view or footer
Expand Down Expand Up @@ -339,35 +338,6 @@ public struct PaywallView: View {
paywallView
}
}
#else
let (paywall, displayedLocale, template, error) = offering.validatedPaywall(locale: self.locale)

let paywallView = LoadedOfferingPaywallView(
offering: offering,
activelySubscribedProductIdentifiers: activelySubscribedProductIdentifiers,
paywall: paywall,
template: template,
mode: self.mode,
fonts: fonts,
displayCloseButton: self.displayCloseButton,
introEligibility: checker,
purchaseHandler: purchaseHandler,
locale: displayedLocale,
showZeroDecimalPlacePrices: showZeroDecimalPlacePrices
)

if let error {
DebugErrorView(
"\(error.description)\n" +
"You can fix this by editing the paywall in the RevenueCat dashboard.\n" +
"The displayed paywall contains default configuration.\n" +
"This error will be hidden in production.",
replacement: paywallView
)
} else {
paywallView
}
#endif
}

// MARK: -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct ButtonComponentView: View {
Expand Down Expand Up @@ -43,9 +43,12 @@ struct ButtonComponentView: View {
#if canImport(SafariServices) && canImport(UIKit)
.sheet(isPresented: .isNotNil($inAppBrowserURL)) {
SafariView(url: inAppBrowserURL!)
}.presentCustomerCenter(isPresented: $showCustomerCenter) {
showCustomerCenter = false
}
#if os(iOS)
.presentCustomerCenter(isPresented: $showCustomerCenter, onDismiss: {
showCustomerCenter = false
})
#endif
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import Foundation
import RevenueCat

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class ButtonComponentViewModel {
Expand Down
2 changes: 1 addition & 1 deletion RevenueCatUI/Templates/V2/Components/ComponentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct ComponentsView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct IconComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

private typealias PresentedIconPartial = PaywallComponent.PartialIconComponent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct ImageComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class ImageComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

enum ComponentViewState {
case `default`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct PackageComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import RevenueCat

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class PackageComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct PurchaseButtonComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class PurchaseButtonComponentViewModel {
Expand Down
2 changes: 1 addition & 1 deletion RevenueCatUI/Templates/V2/Components/Root/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct RootView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class RootViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct FlexHStack: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct FlexVStack: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import RevenueCat

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

enum JustifyContent {
case start, center, end, spaceBetween, spaceAround, spaceEvenly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import SwiftUI

// swiftlint:disable file_length

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct StackComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

typealias PresentedStackPartial = PaywallComponent.PartialStackComponent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct StickyFooterComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class StickyFooterComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct TabControlButtonComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class TabControlButtonComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct TabControlComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class TabControlComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct TabControlToggleComponentView: View {
Expand Down Expand Up @@ -83,7 +83,7 @@ private struct CustomToggleStyle: ToggleStyle {
.offset(x: configuration.isOn ? 10 : -10)
)
.onTapGesture {
withAnimation(.smooth(duration: 0.2)) {
withAnimation(.easeInOut(duration: 0.2)) {
configuration.isOn.toggle()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class TabControlToggleComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class TabControlContext: ObservableObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class TabsComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct TextComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class TextComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct TimelineComponentView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import RevenueCat

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class TimelineComponentViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Combine
import RevenueCat

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@MainActor
class IntroOfferEligibilityContext: ObservableObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import RevenueCat
import SwiftUI

#if PAYWALL_COMPONENTS
#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class PackageContext: ObservableObject {
Expand Down
Loading

0 comments on commit 3d86d7d

Please sign in to comment.