diff --git a/Package.swift b/Package.swift index 2ff047a..fe5a348 100644 --- a/Package.swift +++ b/Package.swift @@ -6,9 +6,20 @@ let package = Package( name: "BetterSafariView", platforms: [.iOS(.v13), .macOS(.v10_15), .watchOS("6.2")], products: [ - .library(name: "BetterSafariView", targets: ["BetterSafariView"]) + .library(name: "BetterSafariView", + targets: ["BetterSafariView"]), + .library(name: "SafariView", + targets: ["SafariView"]), + .library(name: "WebAuthenticationSession", + targets: ["WebAuthenticationSession"]) ], targets: [ - .target(name: "BetterSafariView") + .target(name: "BetterSafariView", + dependencies: ["SafariView", "WebAuthenticationSession"]), + .target(name: "SafariView", + dependencies: ["Shared"]), + .target(name: "WebAuthenticationSession", + dependencies: ["Shared"]), + .target(name: "Shared") ] ) diff --git a/Sources/BetterSafariView/BetterSafariView.swift b/Sources/BetterSafariView/BetterSafariView.swift new file mode 100644 index 0000000..c9621cc --- /dev/null +++ b/Sources/BetterSafariView/BetterSafariView.swift @@ -0,0 +1,2 @@ +@_exported import SafariView +@_exported import WebAuthenticationSession diff --git a/Sources/BetterSafariView/SafariView/SafariView+View.swift b/Sources/SafariView/SafariView+View.swift similarity index 100% rename from Sources/BetterSafariView/SafariView/SafariView+View.swift rename to Sources/SafariView/SafariView+View.swift diff --git a/Sources/BetterSafariView/SafariView/SafariView.swift b/Sources/SafariView/SafariView.swift similarity index 100% rename from Sources/BetterSafariView/SafariView/SafariView.swift rename to Sources/SafariView/SafariView.swift diff --git a/Sources/BetterSafariView/SafariView/SafariViewPresentationModifier.swift b/Sources/SafariView/SafariViewPresentationModifier.swift similarity index 99% rename from Sources/BetterSafariView/SafariView/SafariViewPresentationModifier.swift rename to Sources/SafariView/SafariViewPresentationModifier.swift index 8adca32..04a6207 100644 --- a/Sources/BetterSafariView/SafariView/SafariViewPresentationModifier.swift +++ b/Sources/SafariView/SafariViewPresentationModifier.swift @@ -1,6 +1,7 @@ #if os(iOS) import SwiftUI +import Shared struct SafariViewPresentationModifier: ViewModifier { diff --git a/Sources/BetterSafariView/SafariView/SafariViewPresenter.swift b/Sources/SafariView/SafariViewPresenter.swift similarity index 98% rename from Sources/BetterSafariView/SafariView/SafariViewPresenter.swift rename to Sources/SafariView/SafariViewPresenter.swift index ec98958..a4ce6a2 100644 --- a/Sources/BetterSafariView/SafariView/SafariViewPresenter.swift +++ b/Sources/SafariView/SafariViewPresenter.swift @@ -85,7 +85,7 @@ extension SafariViewPresenter { // when the `UIViewControllerRepresentable` is detached from the root view controller (e.g. `UIViewController` contained in `UITableViewCell`) // while allowing it to be presented even on the modal sheets. // Thanks to: Bohdan Hernandez Navia (@boherna) - guard let presentingViewController = uiView.viewController else { + guard let presentingViewController = uiView._viewController else { self.resetItemBinding() return } diff --git a/Sources/BetterSafariView/Shared/Identifiables.swift b/Sources/Shared/Identifiables.swift similarity index 100% rename from Sources/BetterSafariView/Shared/Identifiables.swift rename to Sources/Shared/Identifiables.swift diff --git a/Sources/BetterSafariView/Shared/UIView+viewController.swift b/Sources/Shared/UIView+viewController.swift similarity index 81% rename from Sources/BetterSafariView/Shared/UIView+viewController.swift rename to Sources/Shared/UIView+viewController.swift index 80aa67c..ffb3dd6 100644 --- a/Sources/BetterSafariView/Shared/UIView+viewController.swift +++ b/Sources/Shared/UIView+viewController.swift @@ -7,11 +7,11 @@ extension UIView { /// The receiver’s view controller, or `nil` if it has none. /// /// This property is `nil` if the view has not yet been added to a view controller. - var viewController: UIViewController? { + public var _viewController: UIViewController? { if let nextResponder = self.next as? UIViewController { return nextResponder } else if let nextResponder = self.next as? UIView { - return nextResponder.viewController + return nextResponder._viewController } else { return nil } diff --git a/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift b/Sources/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift similarity index 99% rename from Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift rename to Sources/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift index e4f0023..a3079ba 100644 --- a/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift +++ b/Sources/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift @@ -1,6 +1,7 @@ #if os(iOS) || os(macOS) || os(watchOS) import SwiftUI +import Shared struct WebAuthenticationPresentationModifier: ViewModifier { diff --git a/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresenter.swift b/Sources/WebAuthenticationSession/WebAuthenticationPresenter.swift similarity index 98% rename from Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresenter.swift rename to Sources/WebAuthenticationSession/WebAuthenticationPresenter.swift index ec664c6..2936e3b 100644 --- a/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresenter.swift +++ b/Sources/WebAuthenticationSession/WebAuthenticationPresenter.swift @@ -199,7 +199,7 @@ extension WebAuthenticationPresenter { @available(iOS, introduced: 13.0, deprecated: 14.0) func setInteractiveDismissalDelegateIfPossible() { - guard let safariViewController = view.viewController?.presentedViewController as? SFSafariViewController else { + guard let safariViewController = view._viewController?.presentedViewController as? SFSafariViewController else { return } safariViewController.presentationController?.delegate = interactiveDismissalDelegate diff --git a/Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationSession.swift b/Sources/WebAuthenticationSession/WebAuthenticationSession.swift similarity index 100% rename from Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationSession.swift rename to Sources/WebAuthenticationSession/WebAuthenticationSession.swift