diff --git a/DependenciesAdditions.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DependenciesAdditions.xcworkspace/xcshareddata/swiftpm/Package.resolved index c3d44cb..1e8468d 100644 --- a/DependenciesAdditions.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DependenciesAdditions.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/combine-schedulers", "state" : { - "revision" : "9fa31f4403da54855f1e2aeaeff478f4f0e40b13", - "version" : "1.0.2" + "revision" : "5928286acce13def418ec36d05a001a9641086f2", + "version" : "1.0.3" } }, { @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-case-paths", "state" : { - "revision" : "71344dd930fde41e8f3adafe260adcbb2fc2a3dc", - "version" : "1.5.4" + "revision" : "41b89b8b68d8c56c622dbb7132258f1a3e638b25", + "version" : "1.7.0" } }, { @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-clocks", "state" : { - "revision" : "3581e280bf0d90c3fb9236fb23e75a5d8c46b533", - "version" : "1.0.4" + "revision" : "cc46202b53476d64e824e0b6612da09d84ffde8e", + "version" : "1.0.6" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-concurrency-extras", "state" : { - "revision" : "bb5059bde9022d69ac516803f4f227d8ac967f71", - "version" : "1.1.0" + "revision" : "82a4ae7170d98d8538ec77238b7eb8e7199ef2e8", + "version" : "1.3.1" } }, { @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-dependencies", "state" : { - "revision" : "d7472be6b3c89251ce4c0db07d32405b43426781", - "version" : "1.3.7" + "revision" : "4c90d6b2b9bf0911af87b103bb40f41771891596", + "version" : "1.9.2" } }, { @@ -59,14 +59,14 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-docc-plugin", "state" : { - "revision" : "26ac5758409154cc448d7ab82389c520fa8a8247", - "version" : "1.3.0" + "revision" : "d1691545d53581400b1de9b0472d45eb25c19fed", + "version" : "1.4.4" } }, { "identity" : "swift-docc-symbolkit", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-docc-symbolkit", + "location" : "https://github.com/swiftlang/swift-docc-symbolkit", "state" : { "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", "version" : "1.0.0" @@ -77,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swiftlang/swift-syntax", "state" : { - "revision" : "515f79b522918f83483068d99c68daeb5116342d", - "version" : "600.0.0-prerelease-2024-08-14" + "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", + "version" : "601.0.1" } }, { @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swiftui-navigation", "state" : { - "revision" : "fc91d591ebba1f90d65028ccb65c861e5979e898", - "version" : "1.5.4" + "revision" : "e628806aeaa9efe25c1abcd97931a7c498fab281", + "version" : "1.5.5" } }, { @@ -95,8 +95,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", "state" : { - "revision" : "c6809a193975cab4d5308c64bd1d51e0df467928", - "version" : "1.2.3" + "revision" : "39de59b2d47f7ef3ca88a039dff3084688fe27f4", + "version" : "1.5.2" } } ], diff --git a/Examples/CaseStudies/CaseStudies/CaseStudiesApp.swift b/Examples/CaseStudies/CaseStudies/CaseStudiesApp.swift index 103e9f0..910d0b7 100644 --- a/Examples/CaseStudies/CaseStudies/CaseStudiesApp.swift +++ b/Examples/CaseStudies/CaseStudies/CaseStudiesApp.swift @@ -1,7 +1,8 @@ import DependenciesAdditions import SwiftUI + #if canImport(UIKit) -import UIKit + import UIKit #endif @main @@ -12,23 +13,23 @@ struct Case_StudiesApp: App { model: withDependencies { $0.persistentContainer = .default(inMemory: true).withInitialData() #if targetEnvironment(simulator) - // Note: This will emit warnings, as using these `$` accessors should only - // be used for previews and testing, but we do so here because the following - // values are undefined when running on the simulator. - // We are furthermore forced to perform a `context` danse to avoid emitting - // runtime warning, as one shouldn't access `$` device properties - // in a `live` context. So we temporarily switch to a `preview` context - // to avoid the warning when we access the values two lines below. - var dependencies = $0 - withDependencies { inner in - inner.context = .preview - } operation: { - dependencies.device.$batteryLevel = 0.72 - dependencies.device.$batteryState = UIDevice.BatteryState.charging - } - $0 = dependencies - $0.device.$isBatteryMonitoringEnabled = .constant(true) - $0.context = .live + // Note: This will emit warnings, as using these `$` accessors should only + // be used for previews and testing, but we do so here because the following + // values are undefined when running on the simulator. + // We are furthermore forced to perform a `context` danse to avoid emitting + // runtime warning, as one shouldn't access `$` device properties + // in a `live` context. So we temporarily switch to a `preview` context + // to avoid the warning when we access the values two lines below. + var dependencies = $0 + withDependencies { inner in + inner.context = .preview + } operation: { + dependencies.device.$batteryLevel = 0.72 + dependencies.device.$batteryState = UIDevice.BatteryState.charging + } + $0 = dependencies + $0.device.$isBatteryMonitoringEnabled = .constant(true) + $0.context = .live #endif } operation: { .init() diff --git a/Examples/CaseStudies/CaseStudies/Studies/CompressionStudy.swift b/Examples/CaseStudies/CaseStudies/Studies/CompressionStudy.swift index 7852a64..8ad95de 100644 --- a/Examples/CaseStudies/CaseStudies/Studies/CompressionStudy.swift +++ b/Examples/CaseStudies/CaseStudies/Studies/CompressionStudy.swift @@ -66,7 +66,7 @@ struct CompressionStudyView: View { } header: { Text("Text") } footer: { - Gauge(value: max(1 - model.compressionRatio, 0), in: 0 ... 1) { + Gauge(value: max(1 - model.compressionRatio, 0), in: 0...1) { Text("Compression Ratio") } currentValueLabel: { Text(model.compressionRatio.formatted(.percent.precision(.fractionLength(0)))) @@ -103,7 +103,7 @@ struct CompressionStudyView: View { #if os(iOS) .listStyle(.grouped) #endif - .navigationTitle("Codable & Compression") + .navigationTitle("Codable & Compression") } } @@ -112,14 +112,14 @@ struct CompressionStudyView_Previews: PreviewProvider { NavigationStack { CompressionStudyView( model: - withDependencies { - let encoder = JSONEncoder() - encoder.outputFormatting.insert(.prettyPrinted) - encoder.outputFormatting.insert(.sortedKeys) - $0.encode = DataEncoder(encoder) - } operation: { - .init() - } + withDependencies { + let encoder = JSONEncoder() + encoder.outputFormatting.insert(.prettyPrinted) + encoder.outputFormatting.insert(.sortedKeys) + $0.encode = DataEncoder(encoder) + } operation: { + .init() + } ) } } diff --git a/Examples/CaseStudies/CaseStudies/Studies/CoreDataStudy.swift b/Examples/CaseStudies/CaseStudies/Studies/CoreDataStudy.swift index 4508aa6..b81362f 100644 --- a/Examples/CaseStudies/CaseStudies/Studies/CoreDataStudy.swift +++ b/Examples/CaseStudies/CaseStudies/Studies/CoreDataStudy.swift @@ -1,8 +1,9 @@ -import _CoreDataDependency -import _SwiftUIDependency import Dependencies import SwiftUI import SwiftUINavigation +import _CoreDataDependency +import _SwiftUIDependency + @MainActor final class CoreDataStudy: ObservableObject { enum Destination { @@ -159,7 +160,9 @@ struct CoreDataStudyView: View { } } } header: { - Text("^[\(songsByYear.count) \("song")](inflect: true) from \(songsByYear.id.formatted(.number.grouping(.never)))") + Text( + "^[\(songsByYear.count) \("song")](inflect: true) from \(songsByYear.id.formatted(.number.grouping(.never)))" + ) } } } @@ -234,7 +237,7 @@ struct AddSongView: View { var body: some View { Form { TextField("Name", text: $model.song.editor.name.emptyIfNil()) - Stepper(value: $model.song.editor.year, in: 1960 ... 1970) { + Stepper(value: $model.song.editor.year, in: 1960...1970) { LabeledContent("Year", value: "\(model.song.year)") } } @@ -260,38 +263,38 @@ struct CoreDataStudyView_Previews: PreviewProvider { NavigationStack { CoreDataStudyView( model: - withDependencies { - $0.persistentContainer = .default(inMemory: true).withInitialData() - } operation: { - CoreDataStudy() - } + withDependencies { + $0.persistentContainer = .default(inMemory: true).withInitialData() + } operation: { + CoreDataStudy() + } ) } // TODO: Having two previews creates navigation glitches. -// NavigationStack { -// AddSongView( -// model: -// withDependencies { -// $0.persistentContainer = .canonical(inMemory: true).withInitialData() -// $0.uuid = .incrementing -// } operation: { -// @Dependency(\.persistentContainer) var persistentContainer -// @Dependency(\.uuid) var uuid -// -// return AddSongModel(song: try! persistentContainer.insert(Song.self) { -// $0.identifier = uuid() -// $0.year = 1970 -// $0.name = "Let it be" -// }) -// } -// ) -// } + // NavigationStack { + // AddSongView( + // model: + // withDependencies { + // $0.persistentContainer = .canonical(inMemory: true).withInitialData() + // $0.uuid = .incrementing + // } operation: { + // @Dependency(\.persistentContainer) var persistentContainer + // @Dependency(\.uuid) var uuid + // + // return AddSongModel(song: try! persistentContainer.insert(Song.self) { + // $0.identifier = uuid() + // $0.year = 1970 + // $0.name = "Let it be" + // }) + // } + // ) + // } } } -public extension Binding { - func nilIfEmpty() -> Binding where Value: RangeReplaceableCollection { +extension Binding { + public func nilIfEmpty() -> Binding where Value: RangeReplaceableCollection { Binding { self.wrappedValue.isEmpty ? nil : self.wrappedValue } set: { newValue, _ in @@ -299,7 +302,7 @@ public extension Binding { } } - func emptyIfNil() -> Binding where Value == T?, T: RangeReplaceableCollection { + public func emptyIfNil() -> Binding where Value == T?, T: RangeReplaceableCollection { Binding { self.wrappedValue ?? .init() } set: { newValue, _ in diff --git a/Examples/CaseStudies/CaseStudies/Studies/Notifications/BatteryStatusStudy.swift b/Examples/CaseStudies/CaseStudies/Studies/Notifications/BatteryStatusStudy.swift index c8b11db..f6439cf 100644 --- a/Examples/CaseStudies/CaseStudies/Studies/Notifications/BatteryStatusStudy.swift +++ b/Examples/CaseStudies/CaseStudies/Studies/Notifications/BatteryStatusStudy.swift @@ -1,164 +1,164 @@ -import _NotificationDependency import Dependencies import NotificationCenterDependency import SwiftUI import SwiftUINavigation +import _NotificationDependency #if os(iOS) -@MainActor -final class BatteryStatusStudy: ObservableObject { - @Published var batteryLevel: Float = 0 - @Published var batteryState: UIDevice.BatteryState = .unknown + @MainActor + final class BatteryStatusStudy: ObservableObject { + @Published var batteryLevel: Float = 0 + @Published var batteryState: UIDevice.BatteryState = .unknown - @Dependency.Notification(\.batteryLevelDidChange) var batteryLevelNotification - @Dependency.Notification(\.batteryStateDidChange) var batteryStateNotification - /// Required to enable/disable notifications in `onAppear`/`onDisappear`. - @Dependency(\.device) var device + @Dependency.Notification(\.batteryLevelDidChange) var batteryLevelNotification + @Dependency.Notification(\.batteryStateDidChange) var batteryStateNotification + /// Required to enable/disable notifications in `onAppear`/`onDisappear`. + @Dependency(\.device) var device - init() { - // Inject the notifications into the `@Published` properties: - self.batteryLevelNotification.assign(to: &self.$batteryLevel) - self.batteryStateNotification.assign(to: &self.$batteryState) - } + init() { + // Inject the notifications into the `@Published` properties: + self.batteryLevelNotification.assign(to: &self.$batteryLevel) + self.batteryStateNotification.assign(to: &self.$batteryState) + } - func onAppear() { - self.device.isBatteryMonitoringEnabled = true - } + func onAppear() { + self.device.isBatteryMonitoringEnabled = true + } - func onDisappear() { - self.device.isBatteryMonitoringEnabled = false + func onDisappear() { + self.device.isBatteryMonitoringEnabled = false + } } -} -struct BatteryStatusStudyView: View { - /// We use a `StateObject.Dependency` which is a special `StateObject` that - /// can capture dependencies when `withDependencies` wraps a whole view instead - /// of only the model's init, like its the case for the preview below. - @StateObject.Dependency var model: BatteryStatusStudy + struct BatteryStatusStudyView: View { + /// We use a `StateObject.Dependency` which is a special `StateObject` that + /// can capture dependencies when `withDependencies` wraps a whole view instead + /// of only the model's init, like its the case for the preview below. + @StateObject.Dependency var model: BatteryStatusStudy - var body: some View { - List { - Section { - LabeledContent("Battery Level") { - HStack { - Text(batteryStateLocalizedText) - Text( - model.batteryLevel.formatted( - .percent.precision(.fractionLength(0))) - ) - .monospacedDigit() - Group { - if model.batteryLevel > 0.875 { - if model.batteryState == .full { - Image(systemName: "battery.100.bolt") + var body: some View { + List { + Section { + LabeledContent("Battery Level") { + HStack { + Text(batteryStateLocalizedText) + Text( + model.batteryLevel.formatted( + .percent.precision(.fractionLength(0))) + ) + .monospacedDigit() + Group { + if model.batteryLevel > 0.875 { + if model.batteryState == .full { + Image(systemName: "battery.100.bolt") + } else { + Image(systemName: "battery.100") + } + } else if model.batteryLevel > 0.625 { + Image(systemName: "battery.75") + } else if model.batteryLevel > 0.375 { + Image(systemName: "battery.50") + } else if model.batteryLevel > 0.125 { + Image(systemName: "battery.25") } else { - Image(systemName: "battery.100") + Image(systemName: "battery.0") } - } else if model.batteryLevel > 0.625 { - Image(systemName: "battery.75") - } else if model.batteryLevel > 0.375 { - Image(systemName: "battery.50") - } else if model.batteryLevel > 0.125 { - Image(systemName: "battery.25") - } else { - Image(systemName: "battery.0") } + .symbolRenderingMode(.multicolor) + .imageScale(.large) } - .symbolRenderingMode(.multicolor) - .imageScale(.large) } + } header: { + Text(#"\\.batteryLevelDidChange"#) + .textCase(.none) + .monospaced() } - } header: { - Text(#"\\.batteryLevelDidChange"#) - .textCase(.none) - .monospaced() } + .onAppear { + model.onAppear() + } + .onDisappear { + model.onDisappear() + } + .navigationTitle("Battery Status") } - .onAppear { - model.onAppear() - } - .onDisappear { - model.onDisappear() - } - .navigationTitle("Battery Status") - } - var batteryStateLocalizedText: String { - switch self.model.batteryState { - case .unknown: - return "Unknown" - case .unplugged: - return "Unplugged" - case .charging: - return "Charging" - case .full: - return "Full" - @unknown default: - return "Unknown" + var batteryStateLocalizedText: String { + switch self.model.batteryState { + case .unknown: + return "Unknown" + case .unplugged: + return "Unplugged" + case .charging: + return "Charging" + case .full: + return "Full" + @unknown default: + return "Unknown" + } } } -} -struct BatteryStatusStudyView_Previews: PreviewProvider { - static var previews: some View { - NavigationStack { - WithState(initialValue: Float(0.72)) { $batteryLevel in - WithState(initialValue: UIDevice.BatteryState.unplugged) { $batteryState in - withDependencies { - $0.device.$isBatteryMonitoringEnabled = .constant(true) - $0.device.$batteryState = { @Sendable in batteryState } - $0.device.$batteryLevel = { @Sendable in batteryLevel } - } operation: { - BatteryStatusStudyView(model: .init()) - .onChange(of: batteryLevel) { _ in - @Dependency(\.notificationCenter) var notificationCenter; - notificationCenter.post(name: UIDevice.batteryLevelDidChangeNotification) - } - .onChange(of: batteryState) { _ in - @Dependency(\.notificationCenter) var notificationCenter; - notificationCenter.post(name: UIDevice.batteryStateDidChangeNotification) - } - .safeAreaInset(edge: .bottom) { - VStack(spacing: 4) { - Text("Preview control (not part of the View)") - .bold() - .frame(maxWidth: .infinity, alignment: .leading) - HStack { - Slider(value: $batteryLevel, in: 0 ... 1) - Text( - "Battery Level: \(batteryLevel.formatted(.percent.precision(.fractionLength(0))))" - ) - } + struct BatteryStatusStudyView_Previews: PreviewProvider { + static var previews: some View { + NavigationStack { + WithState(initialValue: Float(0.72)) { $batteryLevel in + WithState(initialValue: UIDevice.BatteryState.unplugged) { $batteryState in + withDependencies { + $0.device.$isBatteryMonitoringEnabled = .constant(true) + $0.device.$batteryState = { @Sendable in batteryState } + $0.device.$batteryLevel = { @Sendable in batteryLevel } + } operation: { + BatteryStatusStudyView(model: .init()) + .onChange(of: batteryLevel) { _ in + @Dependency(\.notificationCenter) var notificationCenter + notificationCenter.post(name: UIDevice.batteryLevelDidChangeNotification) + } + .onChange(of: batteryState) { _ in + @Dependency(\.notificationCenter) var notificationCenter + notificationCenter.post(name: UIDevice.batteryStateDidChangeNotification) + } + .safeAreaInset(edge: .bottom) { + VStack(spacing: 4) { + Text("Preview control (not part of the View)") + .bold() + .frame(maxWidth: .infinity, alignment: .leading) + HStack { + Slider(value: $batteryLevel, in: 0...1) + Text( + "Battery Level: \(batteryLevel.formatted(.percent.precision(.fractionLength(0))))" + ) + } - Picker(selection: $batteryState) { - Text("Unknown").tag(UIDevice.BatteryState.unknown) - Text("Unplugged").tag(UIDevice.BatteryState.unplugged) - Text("Charging").tag(UIDevice.BatteryState.charging) - Text("Full").tag(UIDevice.BatteryState.full) - } label: { - Text("Battery State") + Picker(selection: $batteryState) { + Text("Unknown").tag(UIDevice.BatteryState.unknown) + Text("Unplugged").tag(UIDevice.BatteryState.unplugged) + Text("Charging").tag(UIDevice.BatteryState.charging) + Text("Full").tag(UIDevice.BatteryState.full) + } label: { + Text("Battery State") + } + .pickerStyle(.segmented) } - .pickerStyle(.segmented) + .font(.footnote) + .foregroundStyle(.secondary) + .padding(8) + .background( + .ultraThinMaterial + .shadow( + .drop( + color: .black.opacity(0.2), + radius: 4 + ) + ), in: ContainerRelativeShape() + ) + .padding(.horizontal) + .containerShape(RoundedRectangle(cornerRadius: 15)) } - .font(.footnote) - .foregroundStyle(.secondary) - .padding(8) - .background( - .ultraThinMaterial - .shadow( - .drop( - color: .black.opacity(0.2), - radius: 4 - ) - ), in: ContainerRelativeShape() - ) - .padding(.horizontal) - .containerShape(RoundedRectangle(cornerRadius: 15)) - } + } } } } } } -} #endif diff --git a/Examples/CaseStudies/CaseStudies/Studies/Notifications/NotificationsStudy.swift b/Examples/CaseStudies/CaseStudies/Studies/Notifications/NotificationsStudy.swift index b9abb55..872ff17 100644 --- a/Examples/CaseStudies/CaseStudies/Studies/Notifications/NotificationsStudy.swift +++ b/Examples/CaseStudies/CaseStudies/Studies/Notifications/NotificationsStudy.swift @@ -1,7 +1,7 @@ -import _NotificationDependency import DependenciesAdditions import SwiftUI import SwiftUINavigation +import _NotificationDependency extension Notification.Name { static var timerNotification = Notification.Name("TimerNotification") @@ -83,7 +83,7 @@ final class CustomNotificationStudy: ObservableObject { func sendRandomNotificationButtonTapped() { self.withRandomNumberGenerator { self.countNotification.post( - Int.random(in: 0 ... 1_000, using: &$0) + Int.random(in: 0...1_000, using: &$0) ) } } diff --git a/Examples/CaseStudies/CaseStudies/Studies/Notifications/UserNotificationsStudy.swift b/Examples/CaseStudies/CaseStudies/Studies/Notifications/UserNotificationsStudy.swift index 86959b6..103b3a0 100644 --- a/Examples/CaseStudies/CaseStudies/Studies/Notifications/UserNotificationsStudy.swift +++ b/Examples/CaseStudies/CaseStudies/Studies/Notifications/UserNotificationsStudy.swift @@ -1,8 +1,8 @@ import Dependencies import DependenciesAdditionsBasics import SwiftUI -import UserNotificationsDependency import UserNotifications +import UserNotificationsDependency final class UserNotificationsStudy: NSObject, ObservableObject { @Dependency(\.userNotificationCenter) var userNotificationCenter @@ -37,9 +37,9 @@ final class UserNotificationsStudy: NSObject, ObservableObject { var canSendNotifications: Bool { #if os(macOS) - self.status == .authorized + self.status == .authorized #else - self.status == .authorized || self.status == .ephemeral + self.status == .authorized || self.status == .ephemeral #endif } @@ -51,7 +51,7 @@ final class UserNotificationsStudy: NSObject, ObservableObject { if self.status == .notDetermined { guard try await self.userNotificationCenter.requestAuthorization(options: [ - .alert, + .alert ]) else { return diff --git a/Examples/CaseStudies/CaseStudies/Studies/SwiftUIEnvironmentStudy.swift b/Examples/CaseStudies/CaseStudies/Studies/SwiftUIEnvironmentStudy.swift index acde9ec..d6618a8 100644 --- a/Examples/CaseStudies/CaseStudies/Studies/SwiftUIEnvironmentStudy.swift +++ b/Examples/CaseStudies/CaseStudies/Studies/SwiftUIEnvironmentStudy.swift @@ -1,7 +1,7 @@ -import _SwiftUIDependency import Dependencies import DependenciesAdditions import SwiftUI +import _SwiftUIDependency @MainActor final class SwiftUIEnvironmentStudy: ObservableObject { diff --git a/Examples/CaseStudies/CaseStudies/Studies/UserDefaultsStudy.swift b/Examples/CaseStudies/CaseStudies/Studies/UserDefaultsStudy.swift index 27c7568..d5a47af 100644 --- a/Examples/CaseStudies/CaseStudies/Studies/UserDefaultsStudy.swift +++ b/Examples/CaseStudies/CaseStudies/Studies/UserDefaultsStudy.swift @@ -1,6 +1,6 @@ -import _AppStorageDependency import Combine import SwiftUI +import _AppStorageDependency @MainActor final class UserDefaultsStudy: ObservableObject { @@ -26,7 +26,7 @@ final class UserDefaultsStudy: ObservableObject { // Automatically save the updated number. self.$publishedNumber .dropFirst() - .removeDuplicates() // We don't want infinite loops + .removeDuplicates() // We don't want infinite loops .debounce(for: .milliseconds(250), scheduler: self.mainQueue) .compactMap { $0 } .sink { [weak self] in @@ -37,7 +37,7 @@ final class UserDefaultsStudy: ObservableObject { // Automatically save the updated string. self.$publishedString .dropFirst() - .removeDuplicates() // We don't want infinite loops + .removeDuplicates() // We don't want infinite loops .debounce(for: .milliseconds(250), scheduler: self.mainQueue) .sink { [weak self] in self?.string = $0 @@ -142,11 +142,14 @@ struct UserDefaultsStudyView: View { value: String(describing: stringFromSwiftUI) ) - TextField("String", text: Binding { - self.model.publishedString ?? "" - } set: { newvalue in - self.model.publishedString = newvalue.isEmpty ? nil : newvalue - }) + TextField( + "String", + text: Binding { + self.model.publishedString ?? "" + } set: { newvalue in + self.model.publishedString = newvalue.isEmpty ? nil : newvalue + } + ) .textFieldStyle(.roundedBorder) Button(role: .destructive) { diff --git a/Examples/CaseStudies/CaseStudies/StudiesView.swift b/Examples/CaseStudies/CaseStudies/StudiesView.swift index 788d4be..b9e308e 100644 --- a/Examples/CaseStudies/CaseStudies/StudiesView.swift +++ b/Examples/CaseStudies/CaseStudies/StudiesView.swift @@ -10,7 +10,7 @@ class StudiesModel: ObservableObject { case coreDataStudy(CoreDataStudy) case notificationStudy(CustomNotificationStudy) #if os(iOS) - case batteryStatusStudy(BatteryStatusStudy) + case batteryStatusStudy(BatteryStatusStudy) #endif case loggerStudy(LoggerStudy) case swiftUIEnvironmentStudy(SwiftUIEnvironmentStudy) @@ -49,11 +49,11 @@ class StudiesModel: ObservableObject { } #if os(iOS) - func batteryStatusStudyButtonTapped() { - self.destination = withDependencies(from: self) { - .batteryStatusStudy(.init()) + func batteryStatusStudyButtonTapped() { + self.destination = withDependencies(from: self) { + .batteryStatusStudy(.init()) + } } - } #endif func loggerStudyButtonTapped() { @@ -114,11 +114,11 @@ struct StudiesView: View { Label("Notification center", systemImage: "envelope") } #if os(iOS) - Button { - self.model.batteryStatusStudyButtonTapped() - } label: { - Label("Battery Status", systemImage: "battery.75") - } + Button { + self.model.batteryStatusStudyButtonTapped() + } label: { + Label("Battery Status", systemImage: "battery.75") + } #endif Button { self.model.userNotificationStudyButtonTapped() @@ -160,12 +160,12 @@ struct StudiesView: View { CustomNotificationStudyView(model: model) } #if os(iOS) - .navigationDestination( - unwrapping: self.$model.destination, - case: /StudiesModel.Destination.batteryStatusStudy - ) { $model in - BatteryStatusStudyView(model: model) - } + .navigationDestination( + unwrapping: self.$model.destination, + case: /StudiesModel.Destination.batteryStatusStudy + ) { $model in + BatteryStatusStudyView(model: model) + } #endif .navigationDestination( unwrapping: self.$model.destination, @@ -193,18 +193,18 @@ struct StudiesView_Previews: PreviewProvider { static var previews: some View { StudiesView( model: - withDependencies { - $0.userDefaults = .standard - $0.persistentContainer = .default(inMemory: true) - .withInitialData() - #if os(iOS) - $0.device.$batteryState = .charging - $0.device.$batteryLevel = 0.72 - $0.device.$isBatteryMonitoringEnabled = .constant(true) - #endif - } operation: { - .init() - } + withDependencies { + $0.userDefaults = .standard + $0.persistentContainer = .default(inMemory: true) + .withInitialData() + #if os(iOS) + $0.device.$batteryState = .charging + $0.device.$batteryLevel = 0.72 + $0.device.$isBatteryMonitoringEnabled = .constant(true) + #endif + } operation: { + .init() + } ) } } diff --git a/Examples/CaseStudies/CaseStudiesTests/AppStorageStudyTests.swift b/Examples/CaseStudies/CaseStudiesTests/AppStorageStudyTests.swift index d5cb2ea..6e612e6 100644 --- a/Examples/CaseStudies/CaseStudiesTests/AppStorageStudyTests.swift +++ b/Examples/CaseStudies/CaseStudiesTests/AppStorageStudyTests.swift @@ -1,29 +1,30 @@ -import XCTest -@testable import CaseStudies +import CombineSchedulers import Dependencies +import XCTest import _AppStorageDependency -import CombineSchedulers + +@testable import CaseStudies @MainActor final class AppStorageStudyTests: XCTestCase { func testAppStorageStudy() async throws { let mainQueue = DispatchQueue.test - try await withDependencies{ + try await withDependencies { $0.userDefaults = .ephemeral() $0.mainQueue = mainQueue.eraseToAnyScheduler() } operation: { @Dependency.AppStorage("number") var number: Int? @Dependency.AppStorage("string") var string: String? - + let model = UserDefaultsStudy() XCTAssertEqual(model.observedNumberValue, nil) XCTAssertEqual(model.observedStringValue, nil) - + await mainQueue.advance(by: .milliseconds(250)) XCTAssertEqual(model.publishedNumber, 42) XCTAssertEqual(model.publishedString, nil) - + model.updateNumberButtonTapped(value: 139) XCTAssertEqual(model.publishedNumber, 139) XCTAssertEqual(number, 42) @@ -32,7 +33,7 @@ final class AppStorageStudyTests: XCTestCase { try await Task.sleep(nanoseconds: NSEC_PER_MSEC * 10) XCTAssertEqual(model.observedNumberValue, 139) - + model.updateNumberButtonTapped(value: 44) XCTAssertEqual(model.publishedNumber, 44) XCTAssertEqual(number, 139) @@ -41,7 +42,7 @@ final class AppStorageStudyTests: XCTestCase { try await Task.sleep(nanoseconds: NSEC_PER_MSEC * 10) XCTAssertEqual(model.observedNumberValue, 44) - + model.resetNumberButtonTapped() XCTAssertEqual(model.publishedNumber, 42) try await Task.sleep(nanoseconds: NSEC_PER_MSEC * 10) diff --git a/Examples/CaseStudies/CaseStudiesTests/BatteryStateStudyTests.swift b/Examples/CaseStudies/CaseStudiesTests/BatteryStateStudyTests.swift index f89473b..15fdeb9 100644 --- a/Examples/CaseStudies/CaseStudiesTests/BatteryStateStudyTests.swift +++ b/Examples/CaseStudies/CaseStudiesTests/BatteryStateStudyTests.swift @@ -7,7 +7,7 @@ import XCTest @MainActor final class BatteryStatusStudyTests: XCTestCase { func testBatteryStatusStudy() async throws { - @Dependency(\.notificationCenter) var notificationCenter; + @Dependency(\.notificationCenter) var notificationCenter @MainActor final class Values { diff --git a/Examples/CaseStudies/CaseStudiesTests/CaseStudiesTests.swift b/Examples/CaseStudies/CaseStudiesTests/CaseStudiesTests.swift index 44d4ba3..b166462 100644 --- a/Examples/CaseStudies/CaseStudiesTests/CaseStudiesTests.swift +++ b/Examples/CaseStudies/CaseStudiesTests/CaseStudiesTests.swift @@ -10,5 +10,4 @@ import XCTest @MainActor final class CaseStudiesTests: XCTestCase { - } diff --git a/Sources/AccessibilityDependency/AccessibilityDependency_iOS.swift b/Sources/AccessibilityDependency/AccessibilityDependency_iOS.swift index 307e655..1576666 100644 --- a/Sources/AccessibilityDependency/AccessibilityDependency_iOS.swift +++ b/Sources/AccessibilityDependency/AccessibilityDependency_iOS.swift @@ -1,6 +1,6 @@ #if os(iOS) || os(tvOS) import Dependencies - @_spi(Internals) import DependenciesAdditionsBasics + import DependenciesAdditionsBasics import Foundation import UIKit import IssueReporting @@ -21,7 +21,7 @@ /// A namespace for accessibility symbols for UIKit apps. public struct Accessibility: Sendable, ConfigurableProxy { - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation public struct Implementation: Sendable { @ReadOnlyProxy public var buttonShapesEnabled: Bool diff --git a/Sources/ApplicationDependency/ApplicationDependency_iOS.swift b/Sources/ApplicationDependency/ApplicationDependency_iOS.swift index 40f5c88..c14f58d 100644 --- a/Sources/ApplicationDependency/ApplicationDependency_iOS.swift +++ b/Sources/ApplicationDependency/ApplicationDependency_iOS.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import Foundation import IssueReporting @@ -22,7 +22,7 @@ import IssueReporting /// The centralized point of control and coordination for apps running in iOS. public struct Application: Sendable, ConfigurableProxy { - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation /// The delegate of the app object. @MainActor diff --git a/Sources/ApplicationDependency/ApplicationDependency_tvOS.swift b/Sources/ApplicationDependency/ApplicationDependency_tvOS.swift index 0362b3e..167d11e 100644 --- a/Sources/ApplicationDependency/ApplicationDependency_tvOS.swift +++ b/Sources/ApplicationDependency/ApplicationDependency_tvOS.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import Foundation import IssueReporting @@ -22,7 +22,7 @@ import IssueReporting /// The centralized point of control and coordination for apps running in iOS. public struct Application: Sendable, ConfigurableProxy { - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation /// The delegate of the app object. @MainActor diff --git a/Sources/BundleDependency/BundleInfo.swift b/Sources/BundleDependency/BundleInfo.swift index 79fe1a4..c5d9c90 100644 --- a/Sources/BundleDependency/BundleInfo.swift +++ b/Sources/BundleDependency/BundleInfo.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import Foundation import IssueReporting @@ -23,7 +23,7 @@ public struct BundleInfo: Sendable, ConfigurableProxy { @ReadOnlyProxy public var version: String } - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation /// A unique identifier for a bundle. public var bundleIdentifier: String { diff --git a/Sources/DependenciesAdditionsBasics/ConcurrencySupport/BroadcastableAsyncSequence.swift b/Sources/DependenciesAdditionsBasics/ConcurrencySupport/BroadcastableAsyncSequence.swift index ec8c55d..aa517c1 100644 --- a/Sources/DependenciesAdditionsBasics/ConcurrencySupport/BroadcastableAsyncSequence.swift +++ b/Sources/DependenciesAdditionsBasics/ConcurrencySupport/BroadcastableAsyncSequence.swift @@ -9,7 +9,7 @@ public protocol BroadcastableAsyncSequence: AsyncSequence {} #if canImport(Combine) extension BroadcastableAsyncSequence { - @_spi(Internals) public func publisher() -> AnyPublisher + public func publisher() -> AnyPublisher where Self: Sendable, Self.Element: Sendable { let subject = CurrentValueSubject(.none) diff --git a/Sources/DependenciesAdditionsBasics/Internal/AsyncSharedSubject.swift b/Sources/DependenciesAdditionsBasics/Internal/AsyncSharedSubject.swift index 9c8b75c..f0737cf 100644 --- a/Sources/DependenciesAdditionsBasics/Internal/AsyncSharedSubject.swift +++ b/Sources/DependenciesAdditionsBasics/Internal/AsyncSharedSubject.swift @@ -3,7 +3,7 @@ import Foundation // A type that is able to broadcast continuation messages to an arbitrary number of // `AsyncStream`s it can generate. -@_spi(Internals) public final class AsyncSharedSubject: Sendable { +public final class AsyncSharedSubject: Sendable { public enum Behavior: Sendable { case replayCurrentValue case awaitForNewValues diff --git a/Sources/DependenciesAdditionsBasics/Proxies.swift b/Sources/DependenciesAdditionsBasics/Proxies.swift index 77a498c..ed0a174 100644 --- a/Sources/DependenciesAdditionsBasics/Proxies.swift +++ b/Sources/DependenciesAdditionsBasics/Proxies.swift @@ -170,7 +170,7 @@ public struct ReadWriteBinding: Sendable { } @available(*, deprecated, message: "Use the two-arguments `get:set:` variant.") - @_spi(Internals) public init(_ getSet: (@Sendable () -> Value, @Sendable (Value) -> Void)) { + public init(_ getSet: (@Sendable () -> Value, @Sendable (Value) -> Void)) { self.get = getSet.0 self.set = getSet.1 } @@ -228,7 +228,6 @@ public struct ReadWriteProxy: Sendable { self.binding = binding } - @_spi(Internals) public var wrappedValue: Value { get { self.binding.get() @@ -279,7 +278,6 @@ public struct ReadOnlyProxy: Sendable { self._value = value } - @_spi(Internals) public var wrappedValue: Value { _value() } @@ -324,7 +322,6 @@ public struct FunctionProxy: Sendable { self._value = value } - @_spi(Internals) public var wrappedValue: Value { _value() } @@ -430,7 +427,7 @@ public struct MainActorReadWriteProxy: Sendable { } @MainActor - @_spi(Internals) + public var wrappedValue: Value { get { self.binding.get() @@ -481,7 +478,7 @@ public struct MainActorReadOnlyProxy: Sendable { self._value = value } @MainActor - @_spi(Internals) + public var wrappedValue: Value { _value() } @@ -509,10 +506,10 @@ public protocol ProxyBindable { } extension ProxyBindable where Self: Sendable { - @_spi(Internals) public var getValue: @Sendable () -> Value { + public var getValue: @Sendable () -> Value { { self.getValueFunction() } } - @_spi(Internals) public var setValue: @Sendable (Value) -> Void { + public var setValue: @Sendable (Value) -> Void { { self.setValueFunction($0) } } } @@ -538,20 +535,20 @@ extension ProxyBindable where Self: Sendable { public struct AnyProxyBindable: ProxyBindable { public var getValue: @Sendable () -> Value public var setValue: @Sendable (Value) -> Void - @_spi(Internals) public func getValueFunction() -> Value { + public func getValueFunction() -> Value { self.getValue() } - @_spi(Internals) public func setValueFunction(_ value: Value) { + public func setValueFunction(_ value: Value) { self.setValue(value) } } extension LockIsolated: ProxyBindable { - @_spi(Internals) public func getValueFunction() -> Value where Value: Sendable { + public func getValueFunction() -> Value where Value: Sendable { self.value } - @_spi(Internals) public func setValueFunction(_ value: Value) where Value: Sendable { + public func setValueFunction(_ value: Value) where Value: Sendable { self.withValue { $0 = value } diff --git a/Sources/DependenciesAdditionsBasics/TestSupport/WithTimeout.swift b/Sources/DependenciesAdditionsBasics/TestSupport/WithTimeout.swift index d6c44bf..4329f75 100644 --- a/Sources/DependenciesAdditionsBasics/TestSupport/WithTimeout.swift +++ b/Sources/DependenciesAdditionsBasics/TestSupport/WithTimeout.swift @@ -11,7 +11,7 @@ import IssueReporting /// - milliseconds: The timeout after which the test fails, in milliseconds. 1000ms by default. /// - description: The description message to show when the test fails. /// - operation: The operation to perform before the timeout expires. -@_spi(Internals) public func withTimeout( +public func withTimeout( _ milliseconds: UInt64 = 1000, description: String = "", operation: @Sendable @escaping () async throws -> Void, @@ -37,7 +37,7 @@ import IssueReporting /// - milliseconds: The timeout after which the test fails, in milliseconds. 1000ms by default. /// - description: The description message to show when the test fails. /// - operations: The operations to perform before the timeout expires. -@_spi(Internals) public func withTimeout( +public func withTimeout( _ milliseconds: UInt64 = 1000, description: String = "", group operations: @escaping @Sendable (inout ThrowingTaskGroup) async throws -> Void, diff --git a/Sources/DeviceDependency/DeviceCheckDependency.swift b/Sources/DeviceDependency/DeviceCheckDependency.swift index 4fa2fff..3275a44 100644 --- a/Sources/DeviceDependency/DeviceCheckDependency.swift +++ b/Sources/DeviceDependency/DeviceCheckDependency.swift @@ -1,6 +1,6 @@ #if canImport(DeviceCheck) import Dependencies - @_spi(Internals) import DependenciesAdditionsBasics + import DependenciesAdditionsBasics import DeviceCheck import IssueReporting @@ -22,7 +22,7 @@ @ReadOnlyProxy public var isSupported: Bool @FunctionProxy public var generateToken: @Sendable () async throws -> Data } - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation /// A Boolean value that indicates whether the device supports the DeviceCheck API. @available(iOS 11.0, macOS 10.15, tvOS 11.0, watchOS 9.0, *) diff --git a/Sources/DeviceDependency/UIDeviceDependency_iOS.swift b/Sources/DeviceDependency/UIDeviceDependency_iOS.swift index ddf278f..7d9ff3d 100644 --- a/Sources/DeviceDependency/UIDeviceDependency_iOS.swift +++ b/Sources/DeviceDependency/UIDeviceDependency_iOS.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import Foundation import IssueReporting @@ -51,7 +51,7 @@ import IssueReporting @FunctionProxy public var playInputClick: @MainActor @Sendable () -> Void } - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation /// The name of the device. @MainActor diff --git a/Sources/DeviceDependency/UIDeviceDependency_tvOS.swift b/Sources/DeviceDependency/UIDeviceDependency_tvOS.swift index 35bba37..1dc7177 100644 --- a/Sources/DeviceDependency/UIDeviceDependency_tvOS.swift +++ b/Sources/DeviceDependency/UIDeviceDependency_tvOS.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import Foundation import IssueReporting @@ -42,7 +42,7 @@ import IssueReporting @FunctionProxy public var playInputClick: @MainActor @Sendable () -> Void } - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation /// The name of the device. @MainActor diff --git a/Sources/DeviceDependency/WKInterfaceDeviceDependency.swift b/Sources/DeviceDependency/WKInterfaceDeviceDependency.swift index 47ee346..b451980 100644 --- a/Sources/DeviceDependency/WKInterfaceDeviceDependency.swift +++ b/Sources/DeviceDependency/WKInterfaceDeviceDependency.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import IssueReporting #if os(watchOS) @@ -50,7 +50,7 @@ import IssueReporting @FunctionProxy public var enableWaterLock: @Sendable () -> Void } - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation /// The name assigned to the underlying device. public var name: String { diff --git a/Sources/PersistentContainerDependency/PersistentContainer.swift b/Sources/PersistentContainerDependency/PersistentContainer.swift index 412dfde..b3b295a 100644 --- a/Sources/PersistentContainerDependency/PersistentContainer.swift +++ b/Sources/PersistentContainerDependency/PersistentContainer.swift @@ -113,7 +113,7 @@ } public struct PersistentContainer: Sendable { - @_spi(Internals) + public let _viewContext: @Sendable () -> NSManagedObjectContext private let _newChildViewContext: @Sendable () -> NSManagedObjectContext private let _newBackgroundContext: @Sendable () -> NSManagedObjectContext diff --git a/Sources/ProcessInfoDependency/ProcessInfoDependency.swift b/Sources/ProcessInfoDependency/ProcessInfoDependency.swift index 09c95bd..31d4c03 100644 --- a/Sources/ProcessInfoDependency/ProcessInfoDependency.swift +++ b/Sources/ProcessInfoDependency/ProcessInfoDependency.swift @@ -1,6 +1,6 @@ #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) import Dependencies - @_spi(Internals) import DependenciesAdditionsBasics + import DependenciesAdditionsBasics import Foundation import IssueReporting @@ -56,7 +56,7 @@ @Sendable (OperatingSystemVersion) -> Bool } - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation } } diff --git a/Sources/UserDefaultsDependency/UserDefaultsDependency.swift b/Sources/UserDefaultsDependency/UserDefaultsDependency.swift index 6dbb755..bcb04fd 100644 --- a/Sources/UserDefaultsDependency/UserDefaultsDependency.swift +++ b/Sources/UserDefaultsDependency/UserDefaultsDependency.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import Foundation extension DependencyValues { @@ -32,13 +32,13 @@ extension UserDefaults { } /// Returns the object associated with the specified key. - @_spi(Internals) + public func object(forKey key: String) -> T? { self._get(key, T.self) as? T } /// Sets the value of the specified default key. - @_spi(Internals) + public func set(_ value: T?, forKey key: String) { self._set(value, key) } @@ -47,7 +47,7 @@ extension UserDefaults { /// the value is removed or if no value exists for the given key. /// - Parameter key: The key that references this user preference. /// - Returns: An `AsyncSequence` of `T?` values, including the initial value. - @_spi(Internals) + public func values(forKey key: String) -> AsyncMapSequence, T?> { self._values(key, T.self).map { $0 as? T } @@ -299,7 +299,7 @@ extension UserDefaults.Dependency: TestDependencyKey { private func _isEqual(_ lhs: (any Sendable)?, _ rhs: (any Sendable)?) -> Bool { switch (lhs, rhs) { - case let (.some(lhs), .some(rhs)): + case (.some(let lhs), .some(let rhs)): return (lhs as! any Equatable).isEqual(other: rhs) case (.none, .none): return type(of: lhs) == type(of: rhs) diff --git a/Sources/UserNotificationsDependency/UserNotificationsDependency.swift b/Sources/UserNotificationsDependency/UserNotificationsDependency.swift index 98f37a1..ec647b4 100644 --- a/Sources/UserNotificationsDependency/UserNotificationsDependency.swift +++ b/Sources/UserNotificationsDependency/UserNotificationsDependency.swift @@ -1,6 +1,6 @@ #if os(iOS) || os(watchOS) || os(macOS) import Dependencies - @_spi(Internals) import DependenciesAdditionsBasics + import DependenciesAdditionsBasics @preconcurrency import UserNotifications import IssueReporting @@ -44,7 +44,7 @@ @Sendable () async -> Set } - @_spi(Internals) public var _implementation: Implementation + public var _implementation: Implementation /// The notification center’s delegate. public var delegate: (UNUserNotificationCenterDelegate & Sendable)? { diff --git a/Sources/_AppStorageDependency/AppStorage+Specializations.swift b/Sources/_AppStorageDependency/AppStorage+Specializations.swift index b4877f8..00892f3 100644 --- a/Sources/_AppStorageDependency/AppStorage+Specializations.swift +++ b/Sources/_AppStorageDependency/AppStorage+Specializations.swift @@ -1,6 +1,6 @@ import Dependencies import Foundation -@_spi(Internals) import UserDefaultsDependency +import UserDefaultsDependency // TODO: Update doc that refers to SwiftUI diff --git a/Sources/_AppStorageDependency/AppStorage.swift b/Sources/_AppStorageDependency/AppStorage.swift index 2c2c9e7..85354f1 100644 --- a/Sources/_AppStorageDependency/AppStorage.swift +++ b/Sources/_AppStorageDependency/AppStorage.swift @@ -2,7 +2,7 @@ @_exported import DependenciesAdditionsBasics import Foundation import IssueReporting -@_spi(Internals) @_exported import UserDefaultsDependency +@_exported import UserDefaultsDependency extension Dependency { @propertyWrapper diff --git a/Sources/_CoreDataDependency/FetchRequest.swift b/Sources/_CoreDataDependency/FetchRequest.swift index a5b1976..6a0ae14 100644 --- a/Sources/_CoreDataDependency/FetchRequest.swift +++ b/Sources/_CoreDataDependency/FetchRequest.swift @@ -3,7 +3,7 @@ @_exported import Dependencies @_exported import DependenciesAdditionsBasics import Foundation - @_spi(Internals) @_exported import PersistentContainerDependency + @_exported import PersistentContainerDependency extension NSFetchRequestResult where Self: NSManagedObject { public typealias Fetched = _CoreDataDependency.Fetched @@ -141,7 +141,7 @@ result = .success(perform(self.object)) } switch result! { - case let .success(value): + case .success(let value): return value } } @@ -209,7 +209,7 @@ result = .success(perform(self.context)) } switch result! { - case let .success(value): + case .success(let value): return value } } diff --git a/Sources/_NotificationDependency/NotificationDependency.swift b/Sources/_NotificationDependency/NotificationDependency.swift index 357bf30..8a09659 100644 --- a/Sources/_NotificationDependency/NotificationDependency.swift +++ b/Sources/_NotificationDependency/NotificationDependency.swift @@ -1,6 +1,6 @@ #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) @_exported import Dependencies - @_spi(Internals) @_exported import DependenciesAdditionsBasics + @_exported import DependenciesAdditionsBasics import Foundation import NotificationCenterDependency diff --git a/Sources/_SwiftUIDependency/SwiftUIEnvironment.swift b/Sources/_SwiftUIDependency/SwiftUIEnvironment.swift index 3ebfca7..80e4432 100644 --- a/Sources/_SwiftUIDependency/SwiftUIEnvironment.swift +++ b/Sources/_SwiftUIDependency/SwiftUIEnvironment.swift @@ -1,7 +1,7 @@ #if canImport(SwiftUI) import Combine @_exported import Dependencies - @_spi(Internals) @_exported import DependenciesAdditionsBasics + @_exported import DependenciesAdditionsBasics import Foundation import SwiftUI @@ -54,7 +54,7 @@ } @MainActor - @_spi(Internals) public final class SwiftUIEnvironment: Sendable, EnvironmentKey, DependencyKey { + public final class SwiftUIEnvironment: Sendable, EnvironmentKey, DependencyKey { struct Key: Hashable, @unchecked Sendable { let id: AnyHashable? let keypath: PartialKeyPath @@ -68,13 +68,13 @@ public nonisolated static var liveValue: SwiftUIEnvironment { .shared } public nonisolated static var testValue: SwiftUIEnvironment { .shared } - @_spi(Internals) public static let shared = SwiftUIEnvironment() + public static let shared = SwiftUIEnvironment() @Published private var dependencies = [Key: Any]() init() {} - @_spi(Internals) public func update( + public func update( _ value: Value?, keyPath: KeyPath, id: ID? = String?.none diff --git a/Tests/DependenciesAdditionsBasicsTests/ProxiesTests.swift b/Tests/DependenciesAdditionsBasicsTests/ProxiesTests.swift index e545363..ab86e1b 100644 --- a/Tests/DependenciesAdditionsBasicsTests/ProxiesTests.swift +++ b/Tests/DependenciesAdditionsBasicsTests/ProxiesTests.swift @@ -1,5 +1,5 @@ //import Dependencies -//@_spi(Internals) import DependenciesAdditionsBasics +// import DependenciesAdditionsBasics //import XCTest //import IssueReporting // diff --git a/Tests/NotificationCenterDependencyTests/NotificationCenterDependencyTests.swift b/Tests/NotificationCenterDependencyTests/NotificationCenterDependencyTests.swift index 878c174..7ec2dbc 100644 --- a/Tests/NotificationCenterDependencyTests/NotificationCenterDependencyTests.swift +++ b/Tests/NotificationCenterDependencyTests/NotificationCenterDependencyTests.swift @@ -1,6 +1,6 @@ #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) import Dependencies - @_spi(Internals) import DependenciesAdditionsBasics + import DependenciesAdditionsBasics import NotificationCenterDependency import XCTest final class NotificationCenterDependencyTests: XCTestCase { diff --git a/Tests/UserDefaultsDependencyTests/UserDefaultsDependencyTests.swift b/Tests/UserDefaultsDependencyTests/UserDefaultsDependencyTests.swift index 7b3ffa1..cf62288 100644 --- a/Tests/UserDefaultsDependencyTests/UserDefaultsDependencyTests.swift +++ b/Tests/UserDefaultsDependencyTests/UserDefaultsDependencyTests.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import UserDefaultsDependency import XCTest diff --git a/Tests/_AppStorageDependencyTests/AppStorageTests.swift b/Tests/_AppStorageDependencyTests/AppStorageTests.swift index 21e1be1..d127b9f 100644 --- a/Tests/_AppStorageDependencyTests/AppStorageTests.swift +++ b/Tests/_AppStorageDependencyTests/AppStorageTests.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import UserDefaultsDependency import XCTest import _AppStorageDependency diff --git a/Tests/_NotificationDependencyTests/NotificationDependencyTests.swift b/Tests/_NotificationDependencyTests/NotificationDependencyTests.swift index 23926f8..66e96d4 100644 --- a/Tests/_NotificationDependencyTests/NotificationDependencyTests.swift +++ b/Tests/_NotificationDependencyTests/NotificationDependencyTests.swift @@ -1,5 +1,5 @@ import Dependencies -@_spi(Internals) import DependenciesAdditionsBasics +import DependenciesAdditionsBasics import XCTest import _NotificationDependency diff --git a/Tests/_SwiftUIDependencyTests/SwiftUIEnvironmentTests.swift b/Tests/_SwiftUIDependencyTests/SwiftUIEnvironmentTests.swift index f98e18d..ab1cf40 100644 --- a/Tests/_SwiftUIDependencyTests/SwiftUIEnvironmentTests.swift +++ b/Tests/_SwiftUIDependencyTests/SwiftUIEnvironmentTests.swift @@ -1,9 +1,9 @@ #if canImport(SwiftUI) import Dependencies - @_spi(Internals) import DependenciesAdditionsBasics + import DependenciesAdditionsBasics import SwiftUI import XCTest - @_spi(Internals) import _SwiftUIDependency + import _SwiftUIDependency enum TestEnvironmentKey: EnvironmentKey { static var defaultValue: Int { 0 }