Skip to content

Commit

Permalink
Support visionOS 1.x (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsanthanam authored Apr 6, 2024
1 parent bb0d706 commit a3d62b0
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/xcodebuild-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let package = Package(
name: "SafariUI",
platforms: [
.iOS(.v14),
.visionOS(.v1),
.macCatalyst(.v14)
],
products: [
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SafariView/DismissButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down
10 changes: 1 addition & 9 deletions Sources/SafariView/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down Expand Up @@ -64,7 +64,6 @@ public extension EnvironmentValues {

}

@available(iOS 14.0, macCatalyst 14.0, *)
extension EnvironmentValues {

var safariViewEntersReaderIfAvailable: Bool {
Expand Down Expand Up @@ -94,7 +93,6 @@ extension EnvironmentValues {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewEntersReaderIfAvailableEnvironmentKey: EnvironmentKey {

// MARK: - EnvironmentKey
Expand All @@ -105,7 +103,6 @@ private struct SafariViewEntersReaderIfAvailableEnvironmentKey: EnvironmentKey {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewBarCollapsingEnabledEnvironmentKey: EnvironmentKey {

// MARK: - EnvironmentKey
Expand All @@ -116,7 +113,6 @@ private struct SafariViewBarCollapsingEnabledEnvironmentKey: EnvironmentKey {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewControlTintColorEnvironmentKey: EnvironmentKey {

// MARK: - EnvironmentKey
Expand All @@ -127,7 +123,6 @@ private struct SafariViewControlTintColorEnvironmentKey: EnvironmentKey {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewBarTintColorEnvironmentKey: EnvironmentKey {

// MARK: - EnvironmentKey
Expand All @@ -138,7 +133,6 @@ private struct SafariViewBarTintColorEnvironmentKey: EnvironmentKey {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewDismissButtonStyleEnvironmentKey: EnvironmentKey {

// MARK: - EnvironmentKey
Expand All @@ -149,7 +143,6 @@ private struct SafariViewDismissButtonStyleEnvironmentKey: EnvironmentKey {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewIncludedActivitiesEnvironmentKey: EnvironmentKey {

// MARK: - EnvironmentKey
Expand All @@ -160,7 +153,6 @@ private struct SafariViewIncludedActivitiesEnvironmentKey: EnvironmentKey {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewExcludedActivityTypesEnvironmentKey: EnvironmentKey {

// MARK: - EnvironmentKey
Expand Down
2 changes: 1 addition & 1 deletion Sources/SafariView/ExcludedActivityTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SafariView/IncludedActivities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down
9 changes: 1 addition & 8 deletions Sources/SafariView/Modifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -224,7 +224,6 @@ public extension View {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewEntersReaderIfAvailableModifier: ViewModifier {

// MARK: - Initializers
Expand All @@ -250,7 +249,6 @@ private struct SafariViewEntersReaderIfAvailableModifier: ViewModifier {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewBarCollapsingEnabledModifier: ViewModifier {

// MARK: - Initializers
Expand All @@ -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
Expand All @@ -301,7 +298,6 @@ private struct SafariViewControlTintColorModifier: ViewModifier {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewBarTintColorModifier: ViewModifier {

// MARK: - Initializers
Expand All @@ -327,7 +323,6 @@ private struct SafariViewBarTintColorModifier: ViewModifier {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewDismissButtonStyleModifier: ViewModifier {

// MARK: - Initializers
Expand All @@ -353,7 +348,6 @@ private struct SafariViewDismissButtonStyleModifier: ViewModifier {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewIncludedActivitiesModifier: ViewModifier {

// MARK: - Initializers
Expand All @@ -379,7 +373,6 @@ private struct SafariViewIncludedActivitiesModifier: ViewModifier {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct SafariViewExcludedActivityTypesModifier: ViewModifier {

// MARK: - Initializers
Expand Down
4 changes: 2 additions & 2 deletions Sources/SafariView/Presentation/BoolPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Sources/SafariView/Presentation/BoolURLPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -85,7 +85,6 @@ public extension View {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct BoolURLPresentation: ViewModifier {

init(
Expand Down
3 changes: 1 addition & 2 deletions Sources/SafariView/Presentation/ItemPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -101,7 +101,6 @@ public extension View {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct ItemModifier<Item>: ViewModifier where Item: Identifiable {

// MARK: - Initializers
Expand Down
3 changes: 1 addition & 2 deletions Sources/SafariView/Presentation/URLPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -78,7 +78,6 @@ public extension View {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct URLPresentation: ViewModifier {

init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -102,7 +102,6 @@ public extension View {

}

@available(iOS 14.0, macCatalyst 14.0, *)
private struct WrappedItemPresentation<Item, ID>: ViewModifier where ID: Hashable {

// MARK: - Initializer
Expand Down
2 changes: 1 addition & 1 deletion Sources/SafariView/PrewarmingToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions Sources/SafariView/SafariView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -120,22 +120,22 @@ 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)
return .init(token, urls: URLs)
}

/// 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)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/WebAuthentication/Modifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/WebAuthentication/Presentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion Sources/WebAuthentication/WebAuthentication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a3d62b0

Please sign in to comment.