Skip to content

Commit a45d93d

Browse files
committed
Add missing SwiftUI compile-time check
1 parent 19cb15f commit a45d93d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

Sources/ComposableArchitecture/Effect.swift

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Foundation
22
import ReactiveSwift
3-
import SwiftUI
3+
#if canImport(SwiftUI)
4+
import SwiftUI
5+
#endif
46
import XCTestDynamicOverlay
57

68
/// The ``Effect`` type encapsulates a unit of work that can be run in the outside world, and can
@@ -316,17 +318,19 @@ public struct Send<Action> {
316318
self.send(action)
317319
}
318320

319-
/// Sends an action back into the system from an effect with animation.
320-
///
321-
/// - Parameters:
322-
/// - action: An action.
323-
/// - animation: An animation.
324-
public func callAsFunction(_ action: Action, animation: Animation?) {
325-
guard !Task.isCancelled else { return }
326-
withAnimation(animation) {
327-
self(action)
321+
#if canImport(SwiftUI)
322+
/// Sends an action back into the system from an effect with animation.
323+
///
324+
/// - Parameters:
325+
/// - action: An action.
326+
/// - animation: An animation.
327+
public func callAsFunction(_ action: Action, animation: Animation?) {
328+
guard !Task.isCancelled else { return }
329+
withAnimation(animation) {
330+
self(action)
331+
}
328332
}
329-
}
333+
#endif
330334
}
331335

332336
// MARK: - Composing Effects

0 commit comments

Comments
 (0)