Skip to content

Commit 9c1575e

Browse files
committed
Fix dependency cycle caused by reciprocalRunway relationship by changing it to computed var
1 parent 951fe25 commit 9c1575e

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

SF50 Shared/Defaults.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SwiftNASR
66
// MARK: - Defaults
77

88
nonisolated(unsafe) private let groupDefaults = UserDefaults(suiteName: "group.codes.tim.TOLD")!
9-
public let latestSchemaVersion = 4
9+
public let latestSchemaVersion = 5
1010

1111
extension Defaults.Keys {
1212
public static let emptyWeight = Key<Measurement<UnitMass>>(

SF50 Shared/Models/Runway.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ public final class Runway {
7575
@Relationship(deleteRule: .cascade, inverse: \NOTAM.runway)
7676
public var notam: NOTAM?
7777

78+
/// Name of the reciprocal runway (e.g., "10R" for runway "28L")
79+
public var reciprocalName: String?
80+
7881
/// The reciprocal runway (opposite direction on same surface)
79-
@Relationship(deleteRule: .nullify)
80-
public var reciprocal: Runway?
82+
public var reciprocal: Runway? {
83+
airport.runways.first { $0.name == reciprocalName }
84+
}
8185

8286
#Unique<Runway>([\.airport, \.name])
8387

@@ -234,7 +238,7 @@ public final class Runway {
234238
_thresholdLatitude = thresholdCoordinate?.latitude
235239
_thresholdLongitude = thresholdCoordinate?.longitude
236240
self.airport = airport
237-
reciprocal = nil
241+
reciprocalName = nil
238242
notam = nil
239243
}
240244

SF50 Shared/Preview Content/Airport Fixtures/ASE.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ extension AirportBuilder {
5252
airport: airport
5353
)
5454

55-
rwy15.reciprocal = rwy33
56-
rwy33.reciprocal = rwy15
55+
rwy15.reciprocalName = "33"
56+
rwy33.reciprocalName = "15"
5757

5858
return [rwy15, rwy33]
5959
}

SF50 TOLD.xcodeproj/xcshareddata/xcschemes/SF50 TOLD.xcscheme

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@
3333
reference = "container:Generate Screenshots/Generate Screenshots.xctestplan">
3434
</TestPlanReference>
3535
<TestPlanReference
36-
reference = "container:SF50 SharedTests/SF50 Shared Unit Tests.xctestplan"
37-
default = "YES">
36+
reference = "container:SF50 SharedTests/SF50 Shared Unit Tests.xctestplan">
3837
</TestPlanReference>
3938
<TestPlanReference
4039
reference = "container:SF50 TOLDUITests/SF50 TOLD UI Tests.xctestplan">
4140
</TestPlanReference>
41+
<TestPlanReference
42+
reference = "container:SF50 TOLDTests/Unit Tests.xctestplan"
43+
default = "YES">
44+
</TestPlanReference>
4245
</TestPlans>
4346
<Testables>
4447
<TestableReference

SF50 TOLD/Loaders/AirportLoader/AirportLoader.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,10 @@ actor AirportLoader {
195195
modelContext.insert(runway)
196196
}
197197

198-
// Link reciprocal runways
198+
// Set reciprocal runway names
199199
for runwayData in airport.runways {
200-
if let reciprocalName = runwayData.reciprocalName,
201-
let runway = runwayMap[runwayData.name],
202-
let reciprocal = runwayMap[reciprocalName]
203-
{
204-
runway.reciprocal = reciprocal
200+
if let runway = runwayMap[runwayData.name] {
201+
runway.reciprocalName = runwayData.reciprocalName
205202
}
206203
}
207204
}

0 commit comments

Comments
 (0)