Skip to content

Commit

Permalink
Move to Swift 5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
vsanthanam committed Mar 31, 2024
1 parent 1234f9b commit 39693b3
Show file tree
Hide file tree
Showing 30 changed files with 77 additions and 1,991 deletions.
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--enable isEmpty
--disable blankLinesAtEndOfScope, blankLinesAtStartOfScope, redundantNilInit, unusedArguments, redundantParens, wrapMultilineStatementBraces, trailingCommas, braces
--swiftversion 5.6
--swiftversion 5.10
--header "NetworkReachability\n{file}\n\nMIT License\n\nCopyright (c) 2021 Varun Santhanam\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\n\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
7 changes: 4 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "a6f583a4a4f7b159d4e80908520b3dbd271958b0a0f434da9f48397ba720bede",
"pins" : [
{
"identity" : "swift-docc-plugin",
Expand All @@ -23,10 +24,10 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/nicklockwood/SwiftFormat",
"state" : {
"revision" : "fee7e1a1ac9518cfe3c4673382368641ccbdc62c",
"version" : "0.51.7"
"revision" : "9e5d0d588ab6e271fe9887ec3dde21d544d4b080",
"version" : "0.53.5"
}
}
],
"version" : 2
"version" : 3
}
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// swift-tools-version: 5.8
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "NetworkReachability",
platforms: [
.iOS(.v11),
.macOS(.v10_13),
.tvOS(.v11),
.watchOS(.v5)
.iOS(.v12),
.macOS(.v10_14),
.tvOS(.v12),
.watchOS(.v6)
],
products: [
.library(
Expand All @@ -19,7 +19,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/nicklockwood/SwiftFormat", exact: "0.51.7")
.package(url: "https://github.com/nicklockwood/SwiftFormat", exact: "0.53.5")
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@

import Foundation

@available(macOS 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public extension Notification.Name {

/// A notification posted by a ``NetworkMonitor`` when its network path changes.
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
static let networkPathChanged: Notification.Name = NetworkMonitor.networkPathChangedNotificationName

#if !os(watchOS)
/// A notification posted by a ``ReachabilityMonitor`` when its reachability gchanges.
static let reachabilityChanged: Notification.Name = ReachabilityMonitor.reachabilityChangedNotificationName
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,5 @@
/// A [`Publisher`](https://developer.apple.com/documentation/combine/publisher) of network path updates
typealias NetworkPathPublisher = NetworkMonitor.Publisher

#if !os(watchOS)
/// A [`Publisher`](https://developer.apple.com/documentation/combine/publisher) of reachability updates
typealias ReachabilityPublisher = ReachabilityMonitor.Publisher
#endif
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@
func request(_ demand: Subscribers.Demand) {
requested += 1
monitor = .withContinuation(pathMonitor: pathMonitor) { [weak self] path in
guard let self = self,
let subscriber = self.subscriber,
self.requested > .none else { return }
self.requested -= .max(1)
guard let self,
let subscriber,
requested > .none else { return }
requested -= .max(1)
let newDemand = subscriber.receive(path)
self.requested += newDemand
requested += newDemand
}
}

Expand Down
24 changes: 12 additions & 12 deletions Sources/NetworkReachability/API/NetworkMonitor/NetworkMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import Network
/// - ``networkPathPublisher(requiringInterfaceType:)``
/// - ``networkPathPublisher(prohibitingInterfaceTypes:)``
/// - ``Publisher``
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public final class NetworkMonitor {

// MARK: - Initializers
Expand Down Expand Up @@ -340,7 +340,7 @@ public final class NetworkMonitor {
let monitor = NWPathMonitor()
monitor.pathUpdateHandler = { path in
monitor.cancel()
if let dispatchQueue = dispatchQueue {
if let dispatchQueue {
dispatchQueue.async {
completionHandler(path)
}
Expand Down Expand Up @@ -418,14 +418,14 @@ public final class NetworkMonitor {
}

private func forward(path: NWPath) {
if let continuation = continuation {
if let continuation {
continuation(path)
} else if let updateQueue = updateQueue {
} else if let updateQueue {
updateQueue.async { [weak self] in
guard let self = self else { return }
self.postNotification()
self.updateDelegate(path: path)
self.updateHandler?(self, path)
guard let self else { return }
postNotification()
updateDelegate(path: path)
updateHandler?(self, path)
}
} else if #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) {
Task {
Expand All @@ -437,10 +437,10 @@ public final class NetworkMonitor {
}
} else {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.postNotification()
self.updateDelegate(path: path)
self.updateHandler?(self, path)
guard let self else { return }
postNotification()
updateDelegate(path: path)
updateHandler?(self, path)
}
}
}
Expand Down
127 changes: 0 additions & 127 deletions Sources/NetworkReachability/API/ReachabilityMonitor/Reachability.swift

This file was deleted.

Loading

0 comments on commit 39693b3

Please sign in to comment.