From 04c2b0acd72a17ab66759f84cb73361d96c3306b Mon Sep 17 00:00:00 2001 From: Eric Lewis Date: Mon, 14 Feb 2022 14:04:27 -0500 Subject: [PATCH] Split into multiple packages. Splitting into multiple packages allows users to import only the package they intend to use, which leads to smaller binary sizes. This is backwards compatible with no changes needed by end users. For users who may not be interested in say web auth sessions, they need only `import SafariView`. fix access control --- Package.swift | 15 +++++++++++++-- Sources/BetterSafariView/BetterSafariView.swift | 2 ++ .../SafariView/SafariView+View.swift | 0 .../SafariView/SafariView.swift | 0 .../SafariViewPresentationModifier.swift | 1 + .../SafariView/SafariViewPresenter.swift | 0 .../Shared/Identifiables.swift | 0 .../Shared/UIView+viewController.swift | 2 +- .../WebAuthenticationPresentationModifier.swift | 1 + .../WebAuthenticationPresenter.swift | 0 .../WebAuthenticationSession.swift | 0 11 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 Sources/BetterSafariView/BetterSafariView.swift rename Sources/{BetterSafariView => }/SafariView/SafariView+View.swift (100%) rename Sources/{BetterSafariView => }/SafariView/SafariView.swift (100%) rename Sources/{BetterSafariView => }/SafariView/SafariViewPresentationModifier.swift (99%) rename Sources/{BetterSafariView => }/SafariView/SafariViewPresenter.swift (100%) rename Sources/{BetterSafariView => }/Shared/Identifiables.swift (100%) rename Sources/{BetterSafariView => }/Shared/UIView+viewController.swift (90%) rename Sources/{BetterSafariView => }/WebAuthenticationSession/WebAuthenticationPresentationModifier.swift (99%) rename Sources/{BetterSafariView => }/WebAuthenticationSession/WebAuthenticationPresenter.swift (100%) rename Sources/{BetterSafariView => }/WebAuthenticationSession/WebAuthenticationSession.swift (100%) 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 100% rename from Sources/BetterSafariView/SafariView/SafariViewPresenter.swift rename to Sources/SafariView/SafariViewPresenter.swift 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 90% rename from Sources/BetterSafariView/Shared/UIView+viewController.swift rename to Sources/Shared/UIView+viewController.swift index 80aa67c..d18ba3c 100644 --- a/Sources/BetterSafariView/Shared/UIView+viewController.swift +++ b/Sources/Shared/UIView+viewController.swift @@ -7,7 +7,7 @@ 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 { 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 100% rename from Sources/BetterSafariView/WebAuthenticationSession/WebAuthenticationPresenter.swift rename to Sources/WebAuthenticationSession/WebAuthenticationPresenter.swift 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