[swiftui] - Fixes warnings - MOB
MODIFY
Sources/SwiftCurrent/TestOnly/TestOnly.swift
Sources/SwiftCurrent/TestOnly/TestOnly.swift
@@ -21,11 +21,7 @@ extension Notification.Name {
extension FlowRepresentable {
/// :nodoc: Your tests may want to manually set the closure so they can make assertions it was called, this is simply a convenience available for that.
public var proceedInWorkflowStorage: ((AnyWorkflow.PassedArgs) -> Void)? {
- get {
- {
- _workflowPointer?.proceedInWorkflowStorage?($0)
- }
- }
+ get { { _workflowPointer?.proceedInWorkflowStorage?($0) } }
set {
_workflowPointer?.proceedInWorkflowStorage = { args in
newValue?(args)
@@ -35,11 +31,7 @@ extension FlowRepresentable {
/// :nodoc: Designed for V1 and V2 people who used to assign to proceedInWorkflow for tests. This auto extracts args.
public var _proceedInWorkflow: ((Any?) -> Void)? {
- get {
- {
- _workflowPointer?.proceedInWorkflowStorage?(.args($0))
- }
- }
+ get { { _workflowPointer?.proceedInWorkflowStorage?(.args($0)) } }
set {
_workflowPointer?.proceedInWorkflowStorage = { args in
newValue?(args.extractArgs(defaultValue: nil))

MODIFY
Sources/SwiftCurrent_SwiftUI/Extensions/AnyWorkflowExtensions.swift
Sources/SwiftCurrent_SwiftUI/Extensions/AnyWorkflowExtensions.swift
-//
+// swiftlint:disable:this file_name
// AnyWorkflowExtensions.swift
// SwiftCurrent
//

MODIFY
Sources/SwiftCurrent_SwiftUI/ViewInspector/Inspection.swift
Sources/SwiftCurrent_SwiftUI/ViewInspector/Inspection.swift
import SwiftUI
import Combine
-#warning("It sucks that we have to modify production code for the sake of tests, but it is absolutely necessary for ViewInspector and totally WORTH IT to get tests around SwiftUI that aren't XCUITests")
+// Necessary for ViewInspector tests
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
final class Inspection<V> where V: View {
let notice = PassthroughSubject<UInt, Never>()

MODIFY
Sources/SwiftCurrent_SwiftUI/Views/WorkflowView.swift
Sources/SwiftCurrent_SwiftUI/Views/WorkflowView.swift
@@ -46,17 +46,16 @@ import SwiftCurrent
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct WorkflowView: View {
@Binding public var isPresented: Bool
- let inspection = Inspection<Self>()
+ let inspection = Inspection<Self>() // Needed for ViewInspector
/// Creates a `WorkflowView` that displays a `FlowRepresentable` when presented.
public init(isPresented: Binding<Bool>) {
_isPresented = .constant(false)
}
- #warning("NOTE: The onReceive is how the tests work...do not remove it if you want tests that work. If you do not want tests that work why precisely are you at WWT or on this project?????")
public var body: some View {
VStack {
- }.onReceive(inspection.notice) { inspection.visit(self, $0) }
+ }.onReceive(inspection.notice) { inspection.visit(self, $0) } // Needed for ViewInspector
}
/// Adds an action to perform when this `Workflow` has finished.

MODIFY
Tests/SwiftCurrent_SwiftUITests/SwiftCurrent_SwiftUITests.swift
Tests/SwiftCurrent_SwiftUITests/SwiftCurrent_SwiftUITests.swift
@@ -83,7 +83,6 @@ final class SwiftCurrent_SwiftUIConsumerTests: XCTestCase {
.thenProceed(with: WorkflowItem(FR6.self))
.thenProceed(with: WorkflowItem(FR7.self)))
.inspection.inspect { viewUnderTest in
- #warning("NOTE: These serve a dual purpose, if the view can't be cast to the appropriate FR# then it fails AND it proceeds in the workflow in 1 line")
XCTAssertNoThrow(try viewUnderTest.find(FR1.self).actualView().proceedInWorkflow())
XCTAssertNoThrow(try viewUnderTest.find(FR2.self).actualView().proceedInWorkflow())
XCTAssertNoThrow(try viewUnderTest.find(FR3.self).actualView().proceedInWorkflow())

MODIFY
Tests/SwiftCurrent_SwiftUITests/ViewInspector/InspectableExtensions.swift
Tests/SwiftCurrent_SwiftUITests/ViewInspector/InspectableExtensions.swift
@@ -11,7 +11,7 @@ import SwiftUI
@testable import SwiftCurrent_SwiftUI
-#warning("Don't forget you need to make every view you want to test with ViewInspector Inspectable")
+// Don't forget you need to make every view you want to test with ViewInspector Inspectable
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension WorkflowView: Inspectable { }

MODIFY
Tests/SwiftCurrent_SwiftUITests/ViewInspector/ViewHostingExtensions.swift
Tests/SwiftCurrent_SwiftUITests/ViewInspector/ViewHostingExtensions.swift
@@ -9,7 +9,6 @@ import Foundation
import SwiftUI
import ViewInspector
-#warning("These are not part of the library, take a look here so you understand what it does")
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ViewHosting {
static func loadView<V: View>(_ view: V) -> V {
@@ -18,19 +17,4 @@ extension ViewHosting {
}
return view
}
-
- #warning("You may not need these, since you do not use environment objects")
- static func loadView<V: View, O: ObservableObject>(_ view: V, data: O) -> V {
- defer {
- Self.host(view: view.environmentObject(data))
- }
- return view
- }
-
- static func loadView<V: View, O: ObservableObject, E>(_ view: V, data: O, keyPath: WritableKeyPath<EnvironmentValues, E>, keyValue: E) -> V {
- defer {
- Self.host(view: view.environmentObject(data).environment(keyPath, keyValue))
- }
- return view
- }
}

[swiftui] - Fixes warnings - MOB