Skip to content

Commit

Permalink
Split into multiple packages.
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
ericlewis committed Feb 14, 2022
1 parent 9c051d2 commit 027ad8e
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 6 deletions.
15 changes: 13 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
]
)
2 changes: 2 additions & 0 deletions Sources/BetterSafariView/BetterSafariView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@_exported import SafariView
@_exported import WebAuthenticationSession
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if os(iOS)

import SwiftUI
import Shared

struct SafariViewPresentationModifier: ViewModifier {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if os(iOS) || os(macOS) || os(watchOS)

import SwiftUI
import Shared

struct WebAuthenticationPresentationModifier: ViewModifier {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 027ad8e

Please sign in to comment.