Skip to content

Commit

Permalink
Added a workaround for a runtime crash when using IDPreference.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjavora committed Jun 1, 2023
1 parent 19f033d commit 0ab2c56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/Orbit/Support/Environment Keys/Identifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,15 @@ public struct IDPreferenceKey: PreferenceKey {
public struct IDPreference: Equatable {
let id: AnyHashable
let bounds: Anchor<CGRect>

// `Anchor` is only conditionally `Equatable` since iOS 15.
// If synthesized, the compiler doesn't see any issues and this leads to a runtime crash on earlier iOS versions.
// That's why this is written here explicitly.
public static func == (lhs: IDPreference, rhs: IDPreference) -> Bool {
if #available(iOS 15, *) {
return lhs.id == rhs.id && lhs.bounds == rhs.bounds
} else {
return lhs.id == rhs.id
}
}
}

0 comments on commit 0ab2c56

Please sign in to comment.