Skip to content

Commit 6142f6f

Browse files
authored
Merge pull request #7 from SchwarzIT/upgrade-network-debugger
Upgrade network debugger
2 parents a8d4af8 + 691cb8b commit 6142f6f

File tree

13 files changed

+23
-179
lines changed

13 files changed

+23
-179
lines changed

NetworkDebugger.podspec

Lines changed: 0 additions & 23 deletions
This file was deleted.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "NetworkDebugger",
8-
platforms: [.iOS(.v14)],
8+
platforms: [.iOS(.v16)],
99
products: [
1010
// Products define the executables and libraries a package produces, and make them visible to other packages.
1111
.library(

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
### Swift Package Manager
2121
Install through the Swift Package Manager using Xcode.
2222

23-
### Cocoa Pods
24-
Add to your `podfile` and install using `pod install`.
25-
```ruby
26-
pod 'NetworkDebugger', '1.0.2'
27-
```
28-
2923
## Setup
3024
In order for the package to work properly, you need to call `start()` as the first method in your `AppDelegate`! (For SwiftUI apps you need to use `@UIApplicationDelegateAdaptor`)
3125
**Note:** It is highly encouraged to only call `start()` in debug or testing environments and **not** in production.

Sources/NetworkDebugger/Extensions/UIApplication+NetworkDebugger.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,10 @@ import UIKit
2222

2323
extension UIApplication {
2424
var ndKeyWindow: UIWindow? {
25-
if #available(iOS 15.0, *) {
26-
return connectedScenes
27-
.sorted { $0.sceneOrder < $1.sceneOrder }
28-
.compactMap { $0 as? UIWindowScene }
29-
.compactMap { $0.keyWindow }
30-
.first
31-
}
32-
return connectedScenes
25+
connectedScenes
3326
.sorted { $0.sceneOrder < $1.sceneOrder }
3427
.compactMap { $0 as? UIWindowScene }
35-
.compactMap { $0.windows.first { $0.isKeyWindow }}
28+
.compactMap { $0.keyWindow }
3629
.first
3730
}
3831
}

Sources/NetworkDebugger/Extensions/URL+NetworkDebugger.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,10 @@ import Foundation
2222

2323
extension URL {
2424
var ndHost: String {
25-
if #available(iOS 16.0, *) {
26-
return host(percentEncoded: false) ?? "N/A"
27-
} else {
28-
return host ?? "N/A"
29-
}
25+
host(percentEncoded: false) ?? "N/A"
3026
}
3127

3228
var ndPath: String {
33-
if #available(iOS 16.0, *) {
34-
return path(percentEncoded: false)
35-
} else {
36-
return path
37-
}
29+
path(percentEncoded: false)
3830
}
3931
}

Sources/NetworkDebugger/Extensions/View+NavigationBarVisible.swift

Lines changed: 0 additions & 23 deletions
This file was deleted.

Sources/NetworkDebugger/Extensions/View+Searchable.swift

Lines changed: 0 additions & 31 deletions
This file was deleted.

Sources/NetworkDebugger/UI/Components/NavigationStack.swift

Lines changed: 0 additions & 38 deletions
This file was deleted.

Sources/NetworkDebugger/UI/Views/Models/ModelView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct ModelView: View {
4646
currentPage
4747
Spacer()
4848
}
49-
.ensureNavigationBarVisible()
5049
}
5150

5251
@ViewBuilder

Sources/NetworkDebugger/UI/Views/NetworkDebuggerView.swift

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,57 +50,44 @@ public struct NetworkDebuggerView: View {
5050
}
5151
}
5252
.sheet(isPresented: $isStatisticsPresented) {
53-
if #available(iOS 16.0, *) {
54-
NavigationStack {
55-
StatisticsView()
56-
.navigationTitle("Statistics")
57-
.navigationBarTitleDisplayMode(.inline)
58-
.toolbar {
59-
ToolbarItem(placement: .primaryAction) {
60-
Button("Done") {
61-
isStatisticsPresented = false
62-
}
53+
NavigationStack {
54+
StatisticsView()
55+
.navigationTitle("Statistics")
56+
.navigationBarTitleDisplayMode(.inline)
57+
.toolbar {
58+
ToolbarItem(placement: .primaryAction) {
59+
Button("Done") {
60+
isStatisticsPresented = false
6361
}
6462
}
65-
}
63+
}
6664
}
6765
}
6866
.toolbar {
6967
isSettingsPresented = true
7068
} statistics: {
7169
isStatisticsPresented = true
7270
}
73-
.ensureNavigationBarVisible()
7471
}
7572
.environmentObject(modelsService)
7673
.environmentObject(settingsService)
7774
.environmentObject(statisticsService)
78-
.searchable(searchText: $searchText)
75+
.searchable(text: $searchText)
7976
}
8077
}
8178

8279
private extension View {
8380
func toolbar(settings: @escaping () -> Void, statistics: @escaping () -> Void) -> some View {
84-
if #available(iOS 16.0, *) {
85-
return self.toolbar {
86-
ToolbarItem(placement: .primaryAction) {
87-
Button("Settings") {
88-
settings()
89-
}
90-
}
91-
ToolbarItem(placement: .cancellationAction) {
92-
Button("Statistics") {
93-
statistics()
94-
95-
}
81+
toolbar {
82+
ToolbarItem(placement: .primaryAction) {
83+
Button("Settings") {
84+
settings()
9685
}
9786
}
98-
} else {
99-
return self.toolbar {
100-
ToolbarItem(placement: .primaryAction) {
101-
Button("Settings") {
102-
settings()
103-
}
87+
ToolbarItem(placement: .cancellationAction) {
88+
Button("Statistics") {
89+
statistics()
90+
10491
}
10592
}
10693
}

0 commit comments

Comments
 (0)