From bba5ce01f57a05840d23ad5f3d53952843d388e6 Mon Sep 17 00:00:00 2001 From: Brian Anglin Date: Sat, 3 Feb 2024 15:22:24 -0800 Subject: [PATCH 1/3] Gets vision os running --- .../SuperwallKit/Debug/SWBounceButton.swift | 2 ++ .../Debug/SWLocalizationViewController.swift | 3 ++- .../Models/SW Product/SWProduct.swift | 4 +++ .../Network/Device Helper/DeviceHelper.swift | 26 ++++++++++++------- .../PaywallViewController.swift | 8 ++++++ .../PaywallMessageHandler.swift | 2 ++ .../Validation/Validation.swift | 4 ++- 7 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Sources/SuperwallKit/Debug/SWBounceButton.swift b/Sources/SuperwallKit/Debug/SWBounceButton.swift index a68308b0c..ddfa32dc3 100644 --- a/Sources/SuperwallKit/Debug/SWBounceButton.swift +++ b/Sources/SuperwallKit/Debug/SWBounceButton.swift @@ -113,7 +113,9 @@ final class SWBounceButton: UIButton { @objc func tappedBounceButton(sender: SWBounceButton) { if isEnabled { + #if !os(visionOS) UIImpactFeedbackGenerator(style: .light).impactOccurred() + #endif // AudioServicesPlayAlertSound(1104) } diff --git a/Sources/SuperwallKit/Debug/SWLocalizationViewController.swift b/Sources/SuperwallKit/Debug/SWLocalizationViewController.swift index 4a0bf25e5..075482b17 100644 --- a/Sources/SuperwallKit/Debug/SWLocalizationViewController.swift +++ b/Sources/SuperwallKit/Debug/SWLocalizationViewController.swift @@ -51,8 +51,9 @@ final class SWLocalizationViewController: UITableViewController { reloadTableView() navigationItem.titleView = searchBar - + #if !os(visionOS) tableView.keyboardDismissMode = .onDrag + #endif navigationController?.navigationBar.tintColor = primaryColor view.tintColor = primaryColor diff --git a/Sources/SuperwallKit/Models/SW Product/SWProduct.swift b/Sources/SuperwallKit/Models/SW Product/SWProduct.swift index 25bd93988..96d4907de 100644 --- a/Sources/SuperwallKit/Models/SW Product/SWProduct.swift +++ b/Sources/SuperwallKit/Models/SW Product/SWProduct.swift @@ -30,7 +30,11 @@ struct SWProduct: Codable { productIdentifier = product.productIdentifier isDownloadable = product.isDownloadable downloadContentLengths = product.downloadContentLengths.map { $0.doubleValue } + #if os(visionOS) + contentVersion = "" + #else contentVersion = product.contentVersion + #endif downloadContentVersion = product.downloadContentVersion if #available(iOS 14.0, *) { diff --git a/Sources/SuperwallKit/Network/Device Helper/DeviceHelper.swift b/Sources/SuperwallKit/Network/Device Helper/DeviceHelper.swift index 2a2272434..c544ec45f 100644 --- a/Sources/SuperwallKit/Network/Device Helper/DeviceHelper.swift +++ b/Sources/SuperwallKit/Network/Device Helper/DeviceHelper.swift @@ -8,7 +8,9 @@ import UIKit import Foundation import SystemConfiguration +#if canImport(CoreTelephony) import CoreTelephony +#endif class DeviceHelper { var locale: String { @@ -119,17 +121,21 @@ class DeviceHelper { } var interfaceStyle: String { - let style = UIScreen.main.traitCollection.userInterfaceStyle - switch style { - case .unspecified: - return "Unspecified" - case .light: - return "Light" - case .dark: - return "Dark" - default: + #if os(visionOS) return "Unknown" - } + #else + let style = UIScreen.main.traitCollection.userInterfaceStyle + switch style { + case .unspecified: + return "Unspecified" + case .light: + return "Light" + case .dark: + return "Dark" + default: + return "Unknown" + } + #endif } var platformWrapper: String? diff --git a/Sources/SuperwallKit/Paywall/View Controller/PaywallViewController.swift b/Sources/SuperwallKit/Paywall/View Controller/PaywallViewController.swift index 226aba21e..e855cab1f 100644 --- a/Sources/SuperwallKit/Paywall/View Controller/PaywallViewController.swift +++ b/Sources/SuperwallKit/Paywall/View Controller/PaywallViewController.swift @@ -188,7 +188,9 @@ public class PaywallViewController: UIViewController, LoadingDelegate { private func configureUI() { modalPresentationCapturesStatusBarAppearance = true + #if !os(visionOS) setNeedsStatusBarAppearanceUpdate() + #endif view.backgroundColor = paywall.backgroundColor view.addSubview(webView) @@ -517,6 +519,7 @@ public class PaywallViewController: UIViewController, LoadingDelegate { modalPresentationStyle = .overFullScreen case .drawer: modalPresentationStyle = .pageSheet + #if !os(visionOS) if #available(iOS 16.0, *), UIDevice.current.userInterfaceIdiom == .phone { sheetPresentationController?.detents = [ @@ -525,6 +528,7 @@ public class PaywallViewController: UIViewController, LoadingDelegate { }) ] } + #endif case .none: break } @@ -610,7 +614,9 @@ extension PaywallViewController: PaywallMessageHandlerDelegate { return } let safariVC = SFSafariViewController(url: url) + #if !os(visionOS) safariVC.delegate = self + #endif self.isSafariVCPresented = true present(safariVC, animated: true) } @@ -881,12 +887,14 @@ extension PaywallViewController { } } +#if !os(visionOS) // MARK: - SFSafariViewControllerDelegate extension PaywallViewController: SFSafariViewControllerDelegate { public func safariViewControllerDidFinish(_ controller: SFSafariViewController) { isSafariVCPresented = false } } +#endif // MARK: - GameControllerDelegate extension PaywallViewController: GameControllerDelegate { diff --git a/Sources/SuperwallKit/Paywall/View Controller/Web View/Message Handling/PaywallMessageHandler.swift b/Sources/SuperwallKit/Paywall/View Controller/Web View/Message Handling/PaywallMessageHandler.swift index 26d7de898..a12d8c54e 100644 --- a/Sources/SuperwallKit/Paywall/View Controller/Web View/Message Handling/PaywallMessageHandler.swift +++ b/Sources/SuperwallKit/Paywall/View Controller/Web View/Message Handling/PaywallMessageHandler.swift @@ -300,6 +300,8 @@ final class PaywallMessageHandler: WebEventDelegate { if Superwall.shared.options.isGameControllerEnabled { return } + #if !os(visionOS) UIImpactFeedbackGenerator().impactOccurred(intensity: 0.7) + #endif } } diff --git a/Sources/SuperwallKit/StoreKit/Products/Receipt Manager/Validation/Validation.swift b/Sources/SuperwallKit/StoreKit/Products/Receipt Manager/Validation/Validation.swift index 3ee87f224..9164d1ea1 100644 --- a/Sources/SuperwallKit/StoreKit/Products/Receipt Manager/Validation/Validation.swift +++ b/Sources/SuperwallKit/StoreKit/Products/Receipt Manager/Validation/Validation.swift @@ -15,6 +15,8 @@ import WatchKit #elseif os(macOS) import IOKit import Cocoa +#else +import VisionKit #endif import CommonCrypto @@ -273,7 +275,7 @@ private func guid() -> Data { return data } return Data() -#elseif !targetEnvironment(macCatalyst) && (os(iOS) || os(tvOS)) +#elseif !targetEnvironment(macCatalyst) && (os(iOS) || os(tvOS) || os(visionOS)) if let identifierForVendor = UIDevice.current.identifierForVendor { var rawUUID = identifierForVendor.uuid let count = MemoryLayout.size(ofValue: rawUUID) From 9c1013334b9ff376c8772771d521adaab10e4ded Mon Sep 17 00:00:00 2001 From: Brian Anglin Date: Sat, 3 Feb 2024 16:58:14 -0800 Subject: [PATCH 2/3] Bump version --- Sources/SuperwallKit/Misc/Constants.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SuperwallKit/Misc/Constants.swift b/Sources/SuperwallKit/Misc/Constants.swift index 40b51f03a..a4e8ae8d8 100644 --- a/Sources/SuperwallKit/Misc/Constants.swift +++ b/Sources/SuperwallKit/Misc/Constants.swift @@ -18,5 +18,5 @@ let sdkVersion = """ */ let sdkVersion = """ -3.4.8 +3.5.0-rc.1 """ From be8be1c7fe0040d1638ba1ea60eff73a7e966226 Mon Sep 17 00:00:00 2001 From: Brian Anglin Date: Sat, 3 Feb 2024 17:03:15 -0800 Subject: [PATCH 3/3] Adds changelog entry --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a0fdd7fd..13b8770be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ The changelog for `SuperwallKit`. Also see the [releases](https://github.com/superwall-me/Superwall-iOS/releases) on GitHub. +## 3.5.0-rc.1 + +This is our first visionOS pre-release, we'll test this on a few devices to +ensure everything works as expected! + +### Enhancements + +- Adds support for visionOS! + ## 3.4.8 ### Enhancements