Skip to content

Commit

Permalink
Merge pull request #586 from kiwicom/585-workaround-for-idpreference-…
Browse files Browse the repository at this point in the history
…crash

Workaround for `IDPreference` crash
  • Loading branch information
PavelHolec authored Jun 1, 2023
2 parents 19f033d + 0ab2c56 commit b5a2477
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 b5a2477

Please sign in to comment.