From 685b0dd3caab481b65b5a5eca738713d3258c914 Mon Sep 17 00:00:00 2001 From: Varun Santhanam Date: Sat, 6 Apr 2024 07:32:45 -0700 Subject: [PATCH] Support visionOS 1.x --- .github/workflows/xcodebuild-build-test.yml | 2 +- Package.swift | 1 + README.md | 3 ++- Sources/SafariView/DismissButtonStyle.swift | 2 +- Sources/SafariView/Environment.swift | 10 +--------- Sources/SafariView/ExcludedActivityTypes.swift | 2 +- Sources/SafariView/IncludedActivities.swift | 2 +- Sources/SafariView/Modifiers.swift | 9 +-------- .../SafariView/Presentation/BoolPresentation.swift | 4 ++-- .../Presentation/BoolURLPresentation.swift | 3 +-- .../SafariView/Presentation/ItemPresentation.swift | 3 +-- .../SafariView/Presentation/URLPresentation.swift | 3 +-- .../Presentation/WrappedItemPresentation.swift | 3 +-- Sources/SafariView/PrewarmingToken.swift | 2 +- Sources/SafariView/SafariView.swift | 14 +++++++------- Sources/WebAuthentication/Modifiers.swift | 2 +- Sources/WebAuthentication/Presentation.swift | 2 +- Sources/WebAuthentication/WebAuthentication.swift | 2 +- 18 files changed, 26 insertions(+), 43 deletions(-) diff --git a/.github/workflows/xcodebuild-build-test.yml b/.github/workflows/xcodebuild-build-test.yml index 311360d09..fc2efa60d 100644 --- a/.github/workflows/xcodebuild-build-test.yml +++ b/.github/workflows/xcodebuild-build-test.yml @@ -16,4 +16,4 @@ jobs: - name: Lint run: swift package plugin --allow-writing-to-package-directory swiftformat --lint - name: Build & Test - run: xcodebuild -scheme 'SafariUI' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' + run: xcodebuild -scheme 'SafariUI' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=17.4' diff --git a/Package.swift b/Package.swift index 0863df2c5..5d6ec2402 100644 --- a/Package.swift +++ b/Package.swift @@ -7,6 +7,7 @@ let package = Package( name: "SafariUI", platforms: [ .iOS(.v14), + .visionOS(.v1), .macCatalyst(.v14) ], products: [ diff --git a/README.md b/README.md index bad91ec37..62ae786ee 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # SafariUI [![MIT License](https://img.shields.io/github/license/vsanthanam/SafariUI)](https://github.com/vsanthanam/SafariUI/blob/main/LICENSE) -[![Package Releases](https://img.shields.io/github/v/release/vsanthanam/SafariUI)](https://github.com/vsanthanam/SafariUI/releases) +[![Release](https://img.shields.io/github/v/release/vsanthanam/SafariUI)](https://github.com/vsanthanam/SafariUI/releases) +[![Pre Release](https://img.shields.io/github/v/release/vsanthanam/SafariUI?include_prereleases)](https://github.com/vsanthanam/SafariUI/releases) [![Build Status](https://img.shields.io/github/actions/workflow/status/vsanthanam/SafariUI/xcodebuild-build-test.yml)](https://github.com/vsanthanam/SafariUI/actions) [![Swift Version](https://img.shields.io/badge/swift-5.10-critical)](https://swift.org) [![Supported Platforms](https://img.shields.io/badge/platform-iOS%2014.0%20%7C%20Catalyst%2014.0-lightgrey)](https://developer.apple.com) diff --git a/Sources/SafariView/DismissButtonStyle.swift b/Sources/SafariView/DismissButtonStyle.swift index 7b34d93e1..fc00add25 100644 --- a/Sources/SafariView/DismissButtonStyle.swift +++ b/Sources/SafariView/DismissButtonStyle.swift @@ -25,7 +25,7 @@ import SafariServices -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension SafariView { /// An enumeration describing the various dismiss buttons styles available in a ``SafariView`` diff --git a/Sources/SafariView/Environment.swift b/Sources/SafariView/Environment.swift index 5b476b9a8..7b21b401a 100644 --- a/Sources/SafariView/Environment.swift +++ b/Sources/SafariView/Environment.swift @@ -25,7 +25,7 @@ import SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension EnvironmentValues { /// The additional activies to include the share sheet displayed inside a ``SafariView`` @@ -64,7 +64,6 @@ public extension EnvironmentValues { } -@available(iOS 14.0, macCatalyst 14.0, *) extension EnvironmentValues { var safariViewEntersReaderIfAvailable: Bool { @@ -94,7 +93,6 @@ extension EnvironmentValues { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewEntersReaderIfAvailableEnvironmentKey: EnvironmentKey { // MARK: - EnvironmentKey @@ -105,7 +103,6 @@ private struct SafariViewEntersReaderIfAvailableEnvironmentKey: EnvironmentKey { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewBarCollapsingEnabledEnvironmentKey: EnvironmentKey { // MARK: - EnvironmentKey @@ -116,7 +113,6 @@ private struct SafariViewBarCollapsingEnabledEnvironmentKey: EnvironmentKey { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewControlTintColorEnvironmentKey: EnvironmentKey { // MARK: - EnvironmentKey @@ -127,7 +123,6 @@ private struct SafariViewControlTintColorEnvironmentKey: EnvironmentKey { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewBarTintColorEnvironmentKey: EnvironmentKey { // MARK: - EnvironmentKey @@ -138,7 +133,6 @@ private struct SafariViewBarTintColorEnvironmentKey: EnvironmentKey { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewDismissButtonStyleEnvironmentKey: EnvironmentKey { // MARK: - EnvironmentKey @@ -149,7 +143,6 @@ private struct SafariViewDismissButtonStyleEnvironmentKey: EnvironmentKey { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewIncludedActivitiesEnvironmentKey: EnvironmentKey { // MARK: - EnvironmentKey @@ -160,7 +153,6 @@ private struct SafariViewIncludedActivitiesEnvironmentKey: EnvironmentKey { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewExcludedActivityTypesEnvironmentKey: EnvironmentKey { // MARK: - EnvironmentKey diff --git a/Sources/SafariView/ExcludedActivityTypes.swift b/Sources/SafariView/ExcludedActivityTypes.swift index c4cb65f8e..000c8c6c7 100644 --- a/Sources/SafariView/ExcludedActivityTypes.swift +++ b/Sources/SafariView/ExcludedActivityTypes.swift @@ -26,7 +26,7 @@ import Foundation import UIKit -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension SafariView { /// A struct used to exclude activity types from the share sheet of a ``SafariView``. diff --git a/Sources/SafariView/IncludedActivities.swift b/Sources/SafariView/IncludedActivities.swift index 3f3ac81a8..9cc3c6dd5 100644 --- a/Sources/SafariView/IncludedActivities.swift +++ b/Sources/SafariView/IncludedActivities.swift @@ -26,7 +26,7 @@ import Foundation import UIKit -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension SafariView { /// A struct used to include custom activities in the share sheet of a ``SafariView`` diff --git a/Sources/SafariView/Modifiers.swift b/Sources/SafariView/Modifiers.swift index 8547da5e2..2edf04cc6 100644 --- a/Sources/SafariView/Modifiers.swift +++ b/Sources/SafariView/Modifiers.swift @@ -25,7 +25,7 @@ import SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension View { /// Set the automatic reader behavior of safari views within this view @@ -224,7 +224,6 @@ public extension View { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewEntersReaderIfAvailableModifier: ViewModifier { // MARK: - Initializers @@ -250,7 +249,6 @@ private struct SafariViewEntersReaderIfAvailableModifier: ViewModifier { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewBarCollapsingEnabledModifier: ViewModifier { // MARK: - Initializers @@ -275,7 +273,6 @@ private struct SafariViewBarCollapsingEnabledModifier: ViewModifier { private let barCollapsingEnabled: Bool } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewControlTintColorModifier: ViewModifier { // MARK: - Initializers @@ -301,7 +298,6 @@ private struct SafariViewControlTintColorModifier: ViewModifier { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewBarTintColorModifier: ViewModifier { // MARK: - Initializers @@ -327,7 +323,6 @@ private struct SafariViewBarTintColorModifier: ViewModifier { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewDismissButtonStyleModifier: ViewModifier { // MARK: - Initializers @@ -353,7 +348,6 @@ private struct SafariViewDismissButtonStyleModifier: ViewModifier { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewIncludedActivitiesModifier: ViewModifier { // MARK: - Initializers @@ -379,7 +373,6 @@ private struct SafariViewIncludedActivitiesModifier: ViewModifier { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct SafariViewExcludedActivityTypesModifier: ViewModifier { // MARK: - Initializers diff --git a/Sources/SafariView/Presentation/BoolPresentation.swift b/Sources/SafariView/Presentation/BoolPresentation.swift index e96d7b2af..db26355ef 100644 --- a/Sources/SafariView/Presentation/BoolPresentation.swift +++ b/Sources/SafariView/Presentation/BoolPresentation.swift @@ -28,7 +28,7 @@ import SafariServices import SwiftUI import UIKit -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension View { /// Presents a ``SafariView`` when a binding to a Boolean value that you provide is `true`. @@ -88,7 +88,7 @@ public extension View { } -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) private struct IsPresentedModifier: ViewModifier { // MARK: - Initializer diff --git a/Sources/SafariView/Presentation/BoolURLPresentation.swift b/Sources/SafariView/Presentation/BoolURLPresentation.swift index ec3ca4b84..12d5d9f8b 100644 --- a/Sources/SafariView/Presentation/BoolURLPresentation.swift +++ b/Sources/SafariView/Presentation/BoolURLPresentation.swift @@ -26,7 +26,7 @@ import Foundation import SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension View { /// Presents a ``SafariView`` when a binding to a Boolean value that you provide is `true`. @@ -85,7 +85,6 @@ public extension View { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct BoolURLPresentation: ViewModifier { init( diff --git a/Sources/SafariView/Presentation/ItemPresentation.swift b/Sources/SafariView/Presentation/ItemPresentation.swift index caeee2ba3..daeb2369c 100644 --- a/Sources/SafariView/Presentation/ItemPresentation.swift +++ b/Sources/SafariView/Presentation/ItemPresentation.swift @@ -28,7 +28,7 @@ import SafariServices import SwiftUI import UIKit -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension View { /// Presents a ``SafariView`` using the given item as a data source for the view’s content. @@ -101,7 +101,6 @@ public extension View { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct ItemModifier: ViewModifier where Item: Identifiable { // MARK: - Initializers diff --git a/Sources/SafariView/Presentation/URLPresentation.swift b/Sources/SafariView/Presentation/URLPresentation.swift index b37dd4950..d0d525cb6 100644 --- a/Sources/SafariView/Presentation/URLPresentation.swift +++ b/Sources/SafariView/Presentation/URLPresentation.swift @@ -26,7 +26,7 @@ import Foundation import SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension View { /// Presents a ``SafariView`` using the given URL. @@ -78,7 +78,6 @@ public extension View { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct URLPresentation: ViewModifier { init( diff --git a/Sources/SafariView/Presentation/WrappedItemPresentation.swift b/Sources/SafariView/Presentation/WrappedItemPresentation.swift index 59871a4d4..f88c3c9e3 100644 --- a/Sources/SafariView/Presentation/WrappedItemPresentation.swift +++ b/Sources/SafariView/Presentation/WrappedItemPresentation.swift @@ -25,7 +25,7 @@ import SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension View { /// Presents a ``SafariView`` using the given item as a data source for the view’s content. @@ -102,7 +102,6 @@ public extension View { } -@available(iOS 14.0, macCatalyst 14.0, *) private struct WrappedItemPresentation: ViewModifier where ID: Hashable { // MARK: - Initializer diff --git a/Sources/SafariView/PrewarmingToken.swift b/Sources/SafariView/PrewarmingToken.swift index 6658e2fec..d18aaf159 100644 --- a/Sources/SafariView/PrewarmingToken.swift +++ b/Sources/SafariView/PrewarmingToken.swift @@ -25,7 +25,7 @@ import SafariServices -@available(iOS 15.0, macCatalyst 15.0, *) +@available(iOS 15.0, visionOS 1.0, macCatalyst 15.0, *) public extension SafariView { /// A type created when SafariServices begins prewarming a connection. diff --git a/Sources/SafariView/SafariView.swift b/Sources/SafariView/SafariView.swift index ffef8fe97..ca4ea8878 100644 --- a/Sources/SafariView/SafariView.swift +++ b/Sources/SafariView/SafariView.swift @@ -29,7 +29,7 @@ import SwiftUI import UIKit /// A wrapper for `SFSafariViewController` in SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public struct SafariView: View { // MARK: - Initializers @@ -61,7 +61,7 @@ public struct SafariView: View { /// - onInitialLoad: Closure to execute on initial load /// - onInitialRedirect: Closure to execute on intial redirect /// - onOpenInBrowser: Closure to execute if a user moves from a `SafariView` to `Safari.app` - @available(iOS 15.0, macCatalyst 15.0, *) + @available(iOS 15.0, visionOS 1.0, macCatalyst 15.0, *) public init( url: URL, activityButton: ActivityButton?, @@ -87,7 +87,7 @@ public struct SafariView: View { /// - onInitialLoad: Closure to execute on initial load /// - onInitialRedirect: Closure to execute on intial redirect /// - onOpenInBrowser: Closure to execute if a user moves from a `SafariView` to `Safari.app` - @available(iOS 15.2, macCatalyst 15.2, *) + @available(iOS 15.2, visionOS 1.0, macCatalyst 15.2, *) public init( url: URL, activityButton: ActivityButton? = nil, @@ -105,7 +105,7 @@ public struct SafariView: View { } /// A convenience typealias for [`SFSafariViewController.ActivityButton`](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/activitybutton) - @available(iOS 15.0, macCatalyst 15.0, *) + @available(iOS 15.0, visionOS 1.0, macCatalyst 15.0, *) public typealias ActivityButton = SFSafariViewController.ActivityButton /// Prewarm the connection to a list of provided URLs @@ -120,7 +120,7 @@ public struct SafariView: View { /// /// - Parameter URLs: The URLs to prewarm /// - Returns: A prewarming token for the provided URLs. - @available(iOS 15.0, macCatalyst 15.0, *) + @available(iOS 15.0, visionOS 1.0, macCatalyst 15.0, *) @discardableResult public static func prewarmConnections(to URLs: [URL]) -> PrewarmingToken { let token = SFSafariViewController.prewarmConnections(to: URLs) @@ -128,14 +128,14 @@ public struct SafariView: View { } /// Clears the safari view's cache using [Swift Concurrency](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/). - @available(iOS 16.0, macCatalyst 16.0, *) + @available(iOS 16.0, visionOS 1.0, macCatalyst 16.0, *) public static func clearWebsiteData() async { await SFSafariViewController.DataStore.default.clearWebsiteData() } /// Clears the safari view's cache using a completion handler. /// - Parameter completionHandler: Closure to execute after the operation completes - @available(iOS 16.0, macCatalyst 16.0, *) + @available(iOS 16.0, visionOS 1.0, macCatalyst 16.0, *) public static func clearWebsiteData(completionHandler: (() -> Void)?) { SFSafariViewController.DataStore.default.clearWebsiteData(completionHandler: completionHandler) } diff --git a/Sources/WebAuthentication/Modifiers.swift b/Sources/WebAuthentication/Modifiers.swift index bda194de8..2b94c9cbf 100644 --- a/Sources/WebAuthentication/Modifiers.swift +++ b/Sources/WebAuthentication/Modifiers.swift @@ -25,7 +25,7 @@ import SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension View { /// Set the private authentication requirements for authentication sessions within this view. diff --git a/Sources/WebAuthentication/Presentation.swift b/Sources/WebAuthentication/Presentation.swift index 45706d4a1..2743b2219 100644 --- a/Sources/WebAuthentication/Presentation.swift +++ b/Sources/WebAuthentication/Presentation.swift @@ -25,7 +25,7 @@ import SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public extension View { /// Presents a ``WebAuthentication`` when a binding to a Boolean value that you provide is `true`. diff --git a/Sources/WebAuthentication/WebAuthentication.swift b/Sources/WebAuthentication/WebAuthentication.swift index 0c7fd6f32..9f0547885 100644 --- a/Sources/WebAuthentication/WebAuthentication.swift +++ b/Sources/WebAuthentication/WebAuthentication.swift @@ -27,7 +27,7 @@ import AuthenticationServices import SwiftUI /// A wrapper for `ASWebAuthenticationSession` in SwiftUI -@available(iOS 14.0, macCatalyst 14.0, *) +@available(iOS 14.0, visionOS 1.0, macCatalyst 14.0, *) public struct WebAuthentication { // MARK: - Initializers