diff --git a/NetworkDebugger.podspec b/NetworkDebugger.podspec deleted file mode 100644 index 2560d84..0000000 --- a/NetworkDebugger.podspec +++ /dev/null @@ -1,23 +0,0 @@ -Pod::Spec.new do |s| - s.name = "NetworkDebugger" - s.version = "1.0.2" - s.summary = "A Swift package designed to view your App's networking activity with minimal setup." - - s.homepage = "https://github.com/schwarzit/swift-network-debugger" - s.license = { - :type => "Apache", - :file => "LICENSE" - } - s.author = { - "Asmeili" => "michael.artes@mail.schwarz" - } - s.source = { - :git => "https://github.com/schwarzit/swift-network-debugger.git", - :tag => s.version.to_s - } - - s.ios.deployment_target = "14.0" - s.swift_version = "5.0" - - s.source_files = "Sources/NetworkDebugger/**/*.{swift}" -end diff --git a/Package.swift b/Package.swift index 893008c..dd29051 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "NetworkDebugger", - platforms: [.iOS(.v14)], + platforms: [.iOS(.v16)], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( diff --git a/README.md b/README.md index 63d819f..ee18eec 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,6 @@ ### Swift Package Manager Install through the Swift Package Manager using Xcode. -### Cocoa Pods -Add to your `podfile` and install using `pod install`. -```ruby -pod 'NetworkDebugger', '1.0.2' -``` - ## Setup 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`) **Note:** It is highly encouraged to only call `start()` in debug or testing environments and **not** in production. diff --git a/Sources/NetworkDebugger/Extensions/UIApplication+NetworkDebugger.swift b/Sources/NetworkDebugger/Extensions/UIApplication+NetworkDebugger.swift index c4b5f52..12fe332 100644 --- a/Sources/NetworkDebugger/Extensions/UIApplication+NetworkDebugger.swift +++ b/Sources/NetworkDebugger/Extensions/UIApplication+NetworkDebugger.swift @@ -22,17 +22,10 @@ import UIKit extension UIApplication { var ndKeyWindow: UIWindow? { - if #available(iOS 15.0, *) { - return connectedScenes - .sorted { $0.sceneOrder < $1.sceneOrder } - .compactMap { $0 as? UIWindowScene } - .compactMap { $0.keyWindow } - .first - } - return connectedScenes + connectedScenes .sorted { $0.sceneOrder < $1.sceneOrder } .compactMap { $0 as? UIWindowScene } - .compactMap { $0.windows.first { $0.isKeyWindow }} + .compactMap { $0.keyWindow } .first } } diff --git a/Sources/NetworkDebugger/Extensions/URL+NetworkDebugger.swift b/Sources/NetworkDebugger/Extensions/URL+NetworkDebugger.swift index f64f456..08e0b3e 100644 --- a/Sources/NetworkDebugger/Extensions/URL+NetworkDebugger.swift +++ b/Sources/NetworkDebugger/Extensions/URL+NetworkDebugger.swift @@ -22,18 +22,10 @@ import Foundation extension URL { var ndHost: String { - if #available(iOS 16.0, *) { - return host(percentEncoded: false) ?? "N/A" - } else { - return host ?? "N/A" - } + host(percentEncoded: false) ?? "N/A" } var ndPath: String { - if #available(iOS 16.0, *) { - return path(percentEncoded: false) - } else { - return path - } + path(percentEncoded: false) } } diff --git a/Sources/NetworkDebugger/Extensions/View+NavigationBarVisible.swift b/Sources/NetworkDebugger/Extensions/View+NavigationBarVisible.swift deleted file mode 100644 index 594a6f2..0000000 --- a/Sources/NetworkDebugger/Extensions/View+NavigationBarVisible.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// View+NavigationBarVisible.swift -// -// -// Created by Michael Artes on 17.03.23. -// - -import SwiftUI - -extension View { - func ensureNavigationBarVisible() -> some View { - if #available(iOS 15.0, *) { - return self.safeAreaInset(edge: .top) { - Color.clear - .frame(height: 0) - .background(.bar) - .border(.black) - } - } else { - return self - } - } -} diff --git a/Sources/NetworkDebugger/Extensions/View+Searchable.swift b/Sources/NetworkDebugger/Extensions/View+Searchable.swift deleted file mode 100644 index 4615abe..0000000 --- a/Sources/NetworkDebugger/Extensions/View+Searchable.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// File.swift -// -// -// Created by Michael Artes on 13.03.23. -// Copyright © 2023 Schwarz IT KG. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import SwiftUI - -extension View { - func searchable(searchText: Binding) -> some View { - if #available(iOS 15.0, *) { - return self.searchable(text: searchText) - } else { - return self - } - } -} diff --git a/Sources/NetworkDebugger/UI/Components/NavigationStack.swift b/Sources/NetworkDebugger/UI/Components/NavigationStack.swift deleted file mode 100644 index 90d5d03..0000000 --- a/Sources/NetworkDebugger/UI/Components/NavigationStack.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// File.swift -// -// -// Created by Michael Artes on 13.03.23. -// Copyright © 2023 Schwarz IT KG. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import SwiftUI - -struct NavigationStack: View { - - private let content: () -> Content - - init(@ViewBuilder content: @escaping () -> Content) { - self.content = content - } - - var body: some View { - if #available(iOS 16.0, *) { - SwiftUI.NavigationStack(root: content) - } else { - NavigationView(content: content) - } - } -} diff --git a/Sources/NetworkDebugger/UI/Views/Models/ModelView.swift b/Sources/NetworkDebugger/UI/Views/Models/ModelView.swift index 7a5b708..a649b99 100644 --- a/Sources/NetworkDebugger/UI/Views/Models/ModelView.swift +++ b/Sources/NetworkDebugger/UI/Views/Models/ModelView.swift @@ -46,7 +46,6 @@ struct ModelView: View { currentPage Spacer() } - .ensureNavigationBarVisible() } @ViewBuilder diff --git a/Sources/NetworkDebugger/UI/Views/NetworkDebuggerView.swift b/Sources/NetworkDebugger/UI/Views/NetworkDebuggerView.swift index 76862d2..6e5c235 100644 --- a/Sources/NetworkDebugger/UI/Views/NetworkDebuggerView.swift +++ b/Sources/NetworkDebugger/UI/Views/NetworkDebuggerView.swift @@ -50,19 +50,17 @@ public struct NetworkDebuggerView: View { } } .sheet(isPresented: $isStatisticsPresented) { - if #available(iOS 16.0, *) { - NavigationStack { - StatisticsView() - .navigationTitle("Statistics") - .navigationBarTitleDisplayMode(.inline) - .toolbar { - ToolbarItem(placement: .primaryAction) { - Button("Done") { - isStatisticsPresented = false - } + NavigationStack { + StatisticsView() + .navigationTitle("Statistics") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .primaryAction) { + Button("Done") { + isStatisticsPresented = false } } - } + } } } .toolbar { @@ -70,37 +68,26 @@ public struct NetworkDebuggerView: View { } statistics: { isStatisticsPresented = true } - .ensureNavigationBarVisible() } .environmentObject(modelsService) .environmentObject(settingsService) .environmentObject(statisticsService) - .searchable(searchText: $searchText) + .searchable(text: $searchText) } } private extension View { func toolbar(settings: @escaping () -> Void, statistics: @escaping () -> Void) -> some View { - if #available(iOS 16.0, *) { - return self.toolbar { - ToolbarItem(placement: .primaryAction) { - Button("Settings") { - settings() - } - } - ToolbarItem(placement: .cancellationAction) { - Button("Statistics") { - statistics() - - } + toolbar { + ToolbarItem(placement: .primaryAction) { + Button("Settings") { + settings() } } - } else { - return self.toolbar { - ToolbarItem(placement: .primaryAction) { - Button("Settings") { - settings() - } + ToolbarItem(placement: .cancellationAction) { + Button("Statistics") { + statistics() + } } } diff --git a/Sources/NetworkDebugger/UI/Views/Settings/SettingsView.swift b/Sources/NetworkDebugger/UI/Views/Settings/SettingsView.swift index c0599b2..a0b3885 100644 --- a/Sources/NetworkDebugger/UI/Views/Settings/SettingsView.swift +++ b/Sources/NetworkDebugger/UI/Views/Settings/SettingsView.swift @@ -89,6 +89,5 @@ struct SettingsView: View { Text("There's nothing here (yet)") } } - .ensureNavigationBarVisible() } } diff --git a/Sources/NetworkDebugger/UI/Views/Statistics/ChartView.swift b/Sources/NetworkDebugger/UI/Views/Statistics/ChartView.swift index 2ec3309..d81aa19 100644 --- a/Sources/NetworkDebugger/UI/Views/Statistics/ChartView.swift +++ b/Sources/NetworkDebugger/UI/Views/Statistics/ChartView.swift @@ -12,7 +12,6 @@ fileprivate enum ChartViewConstants { static let BAR_HEIGHT: CGFloat = 50 } -@available(iOS 16.0, *) struct ChartView: View { typealias Key = String typealias Value = Double @@ -70,7 +69,6 @@ struct ChartView: View { } .navigationTitle(statisticsService.selectedHost) .navigationBarTitleDisplayMode(.inline) - .ensureNavigationBarVisible() } } } @@ -120,7 +118,6 @@ struct ChartView: View { } } -@available(iOS 16.0, *) extension ChartView where Subview == EmptyView { init(limitedHeight: Bool, elements: Dictionary, @ViewBuilder annotationForKey: @escaping (Key) -> Content) { self.init(limitedHeight: limitedHeight, elements: elements, annotationForKey: annotationForKey, hasSubview: false) { diff --git a/Sources/NetworkDebugger/UI/Views/Statistics/StatisticsView.swift b/Sources/NetworkDebugger/UI/Views/Statistics/StatisticsView.swift index fca1c02..892aa13 100644 --- a/Sources/NetworkDebugger/UI/Views/Statistics/StatisticsView.swift +++ b/Sources/NetworkDebugger/UI/Views/Statistics/StatisticsView.swift @@ -8,7 +8,6 @@ import Charts import SwiftUI -@available(iOS 16.0, *) struct StatisticsView: View { @EnvironmentObject var modelsService: ModelsService @EnvironmentObject var statisticsService: StatisticsService @@ -46,7 +45,6 @@ struct StatisticsView: View { } } .navigationTitle("Statistics") - .ensureNavigationBarVisible() } private var amountOfRequests: some View {