Skip to content

Commit a228063

Browse files
authored
[chore]: pre major version bump cleanup (#187)
after bumping our min iOS version to 14 & swift version to 5.7, did a pass to remove some unneeded annotations, and other minor cleanup. - remove unneeded `#if swift(...)` and `@available(iOS, ....)` conditional compilation statements - remove deprecated typealias of `ContainerViewController` - extract target macOS deploy target to versions.rb & standardize to 10.15
1 parent 8d34d05 commit a228063

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+101
-286
lines changed

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let package = Package(
77
name: "Workflow",
88
platforms: [
99
.iOS("14.0"),
10-
.macOS("10.13"),
10+
.macOS("10.15"),
1111
],
1212
products: [
1313
// MARK: Workflow

Samples/ModalContainer/Sources/ModalContainerViewController.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,8 @@ internal final class ModalContainerViewController<ModalScreen: Screen>: ScreenVi
162162

163163
setNeedsStatusBarAppearanceUpdate()
164164

165-
if #available(iOS 11.0, *) {
166-
setNeedsUpdateOfHomeIndicatorAutoHidden()
167-
setNeedsUpdateOfScreenEdgesDeferringSystemGestures()
168-
}
165+
setNeedsUpdateOfHomeIndicatorAutoHidden()
166+
setNeedsUpdateOfScreenEdgesDeferringSystemGestures()
169167

170168
// Set the topmost screen to be the accessibility modal
171169
presentedScreens.last?.viewController.view.accessibilityViewIsModal = true

Samples/SplitScreenContainer/Sources/SplitScreenContainerViewController.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ internal final class SplitScreenContainerViewController<LeadingScreenType: Scree
120120

121121
private extension UIViewController {
122122
var isLayoutDirectionRightToLeft: Bool {
123-
if #available(iOS 10.0, *) {
124-
return traitCollection.layoutDirection == .rightToLeft
125-
} else {
126-
return UIView.userInterfaceLayoutDirection(for: view.semanticContentAttribute) == .rightToLeft
127-
}
123+
return traitCollection.layoutDirection == .rightToLeft
128124
}
129125
}

ViewEnvironment.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
1414

1515
s.swift_versions = [WORKFLOW_SWIFT_VERSION]
1616
s.ios.deployment_target = WORKFLOW_IOS_DEPLOYMENT_TARGET
17-
s.osx.deployment_target = '10.13'
17+
s.osx.deployment_target = WORKFLOW_MACOS_DEPLOYMENT_TARGET
1818

1919
s.source_files = 'ViewEnvironment/Sources/**/*.swift'
2020

Workflow.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
1414

1515
s.swift_versions = [WORKFLOW_SWIFT_VERSION]
1616
s.ios.deployment_target = WORKFLOW_IOS_DEPLOYMENT_TARGET
17-
s.osx.deployment_target = '10.13'
17+
s.osx.deployment_target = WORKFLOW_MACOS_DEPLOYMENT_TARGET
1818

1919
s.source_files = 'Workflow/Sources/*.swift'
2020

Workflow/Sources/Workflow.swift

-34
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
/// }
5050
/// ```
5151
///
52-
#if swift(>=5.7)
5352
public protocol Workflow<Rendering, Output>: AnyWorkflowConvertible {
5453
/// Defines the state that is managed by this workflow.
5554
associatedtype State
@@ -81,39 +80,6 @@ public protocol Workflow<Rendering, Output>: AnyWorkflowConvertible {
8180
/// This will return the child's `Rendering` type after creating or updating the nested workflow.
8281
func render(state: State, context: RenderContext<Self>) -> Rendering
8382
}
84-
#else
85-
public protocol Workflow: AnyWorkflowConvertible {
86-
/// Defines the state that is managed by this workflow.
87-
associatedtype State
88-
89-
/// `Output` defines the type that can be emitted as output events.
90-
associatedtype Output = Never
91-
92-
/// `Rendering` is the type that is produced by the `render` method: it
93-
/// is commonly a view / screen model.
94-
associatedtype Rendering
95-
96-
/// This method is invoked once when a workflow node comes into existence.
97-
///
98-
/// - Returns: The initial state for the workflow.
99-
func makeInitialState() -> State
100-
101-
/// Called when a new workflow is passed down from the parent to an existing workflow node.
102-
///
103-
/// - Parameter previousWorkflow: The workflow before the update.
104-
/// - Parameter state: The current state.
105-
func workflowDidChange(from previousWorkflow: Self, state: inout State)
106-
107-
/// Called by the internal Workflow infrastructure to "render" the current state into `Rendering`.
108-
/// A workflow's `Rendering` type is commonly a view or screen model.
109-
///
110-
/// - Parameter state: The current state.
111-
/// - Parameter context: The workflow context is the composition point for the workflow tree. To use a nested
112-
/// workflow, instantiate it based on the current state, then call `rendered(in:key:outputMap:)`.
113-
/// This will return the child's `Rendering` type after creating or updating the nested workflow.
114-
func render(state: State, context: RenderContext<Self>) -> Rendering
115-
}
116-
#endif
11783

11884
extension Workflow {
11985
public func workflowDidChange(from previousWorkflow: Self, state: inout State) {}

Workflow/Sources/WorkflowLogger.swift

+43-53
Original file line numberDiff line numberDiff line change
@@ -93,44 +93,38 @@ final class WorkflowLogger {
9393
// MARK: Workflows
9494

9595
static func logWorkflowStarted<WorkflowType>(ref: WorkflowNode<WorkflowType>) {
96-
if #available(iOS 12.0, macOS 10.14, *) {
97-
guard WorkflowLogging.config.logLifetimes else { return }
98-
99-
let signpostID = OSSignpostID(log: .active, object: ref)
100-
os_signpost(
101-
.begin,
102-
log: .active,
103-
name: "Alive",
104-
signpostID: signpostID,
105-
"Workflow: %{public}@",
106-
String(describing: WorkflowType.self)
107-
)
108-
}
96+
guard WorkflowLogging.config.logLifetimes else { return }
97+
98+
let signpostID = OSSignpostID(log: .active, object: ref)
99+
os_signpost(
100+
.begin,
101+
log: .active,
102+
name: "Alive",
103+
signpostID: signpostID,
104+
"Workflow: %{public}@",
105+
String(describing: WorkflowType.self)
106+
)
109107
}
110108

111109
static func logWorkflowFinished<WorkflowType>(ref: WorkflowNode<WorkflowType>) {
112-
if #available(iOS 12.0, macOS 10.14, *) {
113-
guard WorkflowLogging.config.logLifetimes else { return }
110+
guard WorkflowLogging.config.logLifetimes else { return }
114111

115-
let signpostID = OSSignpostID(log: .active, object: ref)
116-
os_signpost(.end, log: .active, name: "Alive", signpostID: signpostID)
117-
}
112+
let signpostID = OSSignpostID(log: .active, object: ref)
113+
os_signpost(.end, log: .active, name: "Alive", signpostID: signpostID)
118114
}
119115

120116
static func logSinkEvent<Action: WorkflowAction>(ref: AnyObject, action: Action) {
121-
if #available(iOS 12.0, macOS 10.14, *) {
122-
guard WorkflowLogging.config.logActions else { return }
123-
124-
let signpostID = OSSignpostID(log: .active, object: ref)
125-
os_signpost(
126-
.event,
127-
log: .active,
128-
name: "Sink Event",
129-
signpostID: signpostID,
130-
"Event for workflow: %{public}@",
131-
String(describing: Action.WorkflowType.self)
132-
)
133-
}
117+
guard WorkflowLogging.config.logActions else { return }
118+
119+
let signpostID = OSSignpostID(log: .active, object: ref)
120+
os_signpost(
121+
.event,
122+
log: .active,
123+
name: "Sink Event",
124+
signpostID: signpostID,
125+
"Event for workflow: %{public}@",
126+
String(describing: Action.WorkflowType.self)
127+
)
134128
}
135129

136130
// MARK: Rendering
@@ -139,35 +133,31 @@ final class WorkflowLogger {
139133
ref: WorkflowNode<WorkflowType>,
140134
isRootNode: Bool
141135
) {
142-
if #available(iOS 12.0, macOS 10.14, *) {
143-
guard shouldLogRenderTimings(
144-
isRootNode: isRootNode
145-
) else { return }
146-
147-
let signpostID = OSSignpostID(log: .active, object: ref)
148-
os_signpost(
149-
.begin,
150-
log: .active,
151-
name: "Render",
152-
signpostID: signpostID,
153-
"Render Workflow: %{public}@",
154-
String(describing: WorkflowType.self)
155-
)
156-
}
136+
guard shouldLogRenderTimings(
137+
isRootNode: isRootNode
138+
) else { return }
139+
140+
let signpostID = OSSignpostID(log: .active, object: ref)
141+
os_signpost(
142+
.begin,
143+
log: .active,
144+
name: "Render",
145+
signpostID: signpostID,
146+
"Render Workflow: %{public}@",
147+
String(describing: WorkflowType.self)
148+
)
157149
}
158150

159151
static func logWorkflowFinishedRendering<WorkflowType>(
160152
ref: WorkflowNode<WorkflowType>,
161153
isRootNode: Bool
162154
) {
163-
if #available(iOS 12.0, macOS 10.14, *) {
164-
guard shouldLogRenderTimings(
165-
isRootNode: isRootNode
166-
) else { return }
155+
guard shouldLogRenderTimings(
156+
isRootNode: isRootNode
157+
) else { return }
167158

168-
let signpostID = OSSignpostID(log: .active, object: ref)
169-
os_signpost(.end, log: .active, name: "Render", signpostID: signpostID)
170-
}
159+
let signpostID = OSSignpostID(log: .active, object: ref)
160+
os_signpost(.end, log: .active, name: "Render", signpostID: signpostID)
171161
}
172162

173163
// MARK: - Utilities

WorkflowCombine.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
1414

1515
s.swift_versions = [WORKFLOW_SWIFT_VERSION]
1616
s.ios.deployment_target = WORKFLOW_IOS_DEPLOYMENT_TARGET
17-
s.osx.deployment_target = '10.15'
17+
s.osx.deployment_target = WORKFLOW_MACOS_DEPLOYMENT_TARGET
1818

1919
s.source_files = 'WorkflowCombine/Sources/*.swift'
2020

WorkflowCombine/Sources/Logger.swift

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ private extension OSLog {
2020
static let worker = OSLog(subsystem: "com.squareup.WorkflowCombine", category: "Worker")
2121
}
2222

23-
@available(iOS 13.0, macOS 10.15, *)
2423
/// Logs Worker events to OSLog
2524
final class WorkerLogger<WorkerType: Worker> {
2625
init() {}

WorkflowCombine/Sources/Publisher+Extensions.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
// Created by Soo Rin Park on 11/3/21.
66
//
77

8-
#if canImport(Combine) && swift(>=5.1)
8+
#if canImport(Combine)
99

1010
import Combine
1111
import Foundation
1212
import Workflow
1313

14-
@available(iOS 13.0, macOS 10.15, *)
1514
/// This is a workaround to the fact you extensions of protocols cannot have an inheritance clause.
1615
/// a previous solution had extending the `AnyPublisher` to conform to `AnyWorkflowConvertible`,
1716
/// but was limited in the fact that rendering was only available to `AnyPublisher`s.

WorkflowCombine/Sources/PublisherWorkflow.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
#if canImport(Combine) && swift(>=5.1)
17+
#if canImport(Combine)
1818

1919
import Combine
2020
import Foundation
2121
import Workflow
2222

23-
@available(iOS 13.0, macOS 10.15, *)
2423
struct PublisherWorkflow<WorkflowPublisher: Publisher>: Workflow where WorkflowPublisher.Failure == Never {
2524
public typealias Output = WorkflowPublisher.Output
2625
public typealias State = Void

WorkflowCombine/Sources/Worker.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
#if canImport(Combine) && swift(>=5.1)
17+
#if canImport(Combine)
1818

1919
import Combine
2020
import Foundation
@@ -28,7 +28,6 @@ import Workflow
2828
/// If there is, and if the workers are 'equivalent', the context leaves the existing worker running.
2929
///
3030
/// If there is not an existing worker of this type, the context will kick off the new worker (via `run`).
31-
@available(iOS 13.0, macOS 10.15, *)
3231
public protocol Worker: AnyWorkflowConvertible where Rendering == Void {
3332
/// The type of output events returned by this worker.
3433
associatedtype Output
@@ -43,14 +42,12 @@ public protocol Worker: AnyWorkflowConvertible where Rendering == Void {
4342
func isEquivalent(to otherWorker: Self) -> Bool
4443
}
4544

46-
@available(iOS 13.0, macOS 10.15, *)
4745
extension Worker {
4846
public func asAnyWorkflow() -> AnyWorkflow<Void, Output> {
4947
WorkerWorkflow(worker: self).asAnyWorkflow()
5048
}
5149
}
5250

53-
@available(iOS 13.0, macOS 10.15, *)
5451
struct WorkerWorkflow<WorkerType: Worker>: Workflow {
5552
let worker: WorkerType
5653

@@ -92,7 +89,6 @@ struct WorkerWorkflow<WorkerType: Worker>: Workflow {
9289
}
9390
}
9491

95-
@available(iOS 13.0, macOS 10.15, *)
9692
extension Worker where Self: Equatable {
9793
public func isEquivalent(to otherWorker: Self) -> Bool {
9894
self == otherWorker

WorkflowCombine/Testing/PublisherTesting.swift

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import WorkflowTesting
2222
import XCTest
2323
@testable import WorkflowCombine
2424

25-
@available(macOS 10.15, *)
26-
@available(iOS 13.0, *)
2725
extension RenderTester {
2826
/// Expect a `Publisher`s.
2927
///

WorkflowCombine/Testing/WorkerTesting.swift

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import WorkflowTesting
2020
import XCTest
2121
@testable import WorkflowCombine
2222

23-
@available(macOS 10.15, *)
24-
@available(iOS 13.0, *)
2523
extension RenderTester {
2624
/// Expect the given worker. It will be checked for `isEquivalent(to:)` with the requested worker.
2725
///

WorkflowCombine/TestingTests/PublisherTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import WorkflowTesting
1212
import XCTest
1313
@testable import WorkflowCombineTesting
1414

15-
@available(iOS 13.0, macOS 10.15, *)
1615
class PublisherTests: XCTestCase {
1716
func testPublisherWorkflow() {
1817
TestWorkflow()

WorkflowCombine/TestingTests/TestingTests.swift

-18
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import WorkflowCombineTesting
2121
import WorkflowTesting
2222
import XCTest
2323

24-
@available(iOS 13.0, macOS 10.15, *)
2524
class WorkflowCombineTestingTests: XCTestCase {
2625
func test_workers() {
2726
let renderTester = TestWorkflow()
@@ -125,8 +124,6 @@ class WorkflowCombineTestingTests: XCTestCase {
125124
}
126125
}
127126

128-
#if swift(>=5.3)
129-
130127
// Undeprecated API on Xcode 12+ (which ships with Swift 5.3)
131128
override func record(_ issue: XCTIssue) {
132129
if removeFailure(withDescription: issue.compactDescription) {
@@ -135,22 +132,8 @@ class WorkflowCombineTestingTests: XCTestCase {
135132
super.record(issue)
136133
}
137134
}
138-
139-
#else
140-
141-
// Otherwise, use old API
142-
override func recordFailure(withDescription description: String, inFile filePath: String, atLine lineNumber: Int, expected: Bool) {
143-
if removeFailure(withDescription: description) {
144-
// Don’t forward the failure, it was expected
145-
} else {
146-
super.recordFailure(withDescription: description, inFile: filePath, atLine: lineNumber, expected: expected)
147-
}
148-
}
149-
150-
#endif
151135
}
152136

153-
@available(iOS 13.0, macOS 10.15, *)
154137
private struct TestWorkflow: Workflow {
155138
struct State: Equatable {
156139
enum Mode: Equatable {
@@ -185,7 +168,6 @@ private struct TestWorkflow: Workflow {
185168
}
186169
}
187170

188-
@available(iOS 13.0, macOS 10.15, *)
189171
private struct TestWorker: Worker {
190172
typealias Output = String
191173
typealias WorkerPublisher = Just<Output>

WorkflowCombine/Tests/PublisherTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import WorkflowCombineTesting
2121
import XCTest
2222
@testable import WorkflowCombine
2323

24-
@available(iOS 13.0, macOS 10.15, *)
2524
class PublisherTests: XCTestCase {
2625
func test_publisherWorkflow_usesSideEffectWithKey() {
2726
PublisherWorkflow(publisher: Just(1))

0 commit comments

Comments
 (0)