Skip to content

Commit 88acee4

Browse files
authored
Merge pull request #18 from ReactiveCocoa/anders/xcode-12
Fix Xcode 12 compiler segfault in EnvironmentLoop.
2 parents 7c417f7 + ca997b5 commit 88acee4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Loop/Public/SwiftUI/EnvironmentLoop.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import ReactiveSwift
77
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
88
@propertyWrapper
99
public struct EnvironmentLoop<State, Event>: DynamicProperty {
10-
@Environment(\.loops[LoopType(Loop<State, Event>.self)])
11-
var erasedLoop: AnyObject?
10+
static var loopType: LoopType { LoopType(Loop<State, Event>.self) }
11+
12+
@Environment(\.loops)
13+
var erasedLoops: [LoopType: AnyObject]
1214

1315
@ObservedObject
1416
private var subscription: SwiftUIHotSwappableSubscription<State, Event>
@@ -19,7 +21,7 @@ public struct EnvironmentLoop<State, Event>: DynamicProperty {
1921
}
2022

2123
public var projectedValue: LoopBinding<State, Event> {
22-
guard let loop = erasedLoop as! Loop<State, Event>? else {
24+
guard let loop = erasedLoops[Self.loopType] as! Loop<State, Event>? else {
2325
fatalError("Scoped bindings can only be created inside the view body.")
2426
}
2527

@@ -34,7 +36,7 @@ public struct EnvironmentLoop<State, Event>: DynamicProperty {
3436
}
3537

3638
public mutating func update() {
37-
guard let loop = erasedLoop as! Loop<State, Event>? else {
39+
guard let loop = erasedLoops[Self.loopType] as! Loop<State, Event>? else {
3840
fatalError("Expect parent view to inject a `Loop<\(State.self), \(Event.self)>` through `View.environmentLoop(_:)`. Found none.")
3941
}
4042

0 commit comments

Comments
 (0)