Skip to content

Commit b5a2477

Browse files
authored
Merge pull request #586 from kiwicom/585-workaround-for-idpreference-crash
Workaround for `IDPreference` crash
2 parents 19f033d + 0ab2c56 commit b5a2477

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/Orbit/Support/Environment Keys/Identifier.swift

+11
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,15 @@ public struct IDPreferenceKey: PreferenceKey {
4141
public struct IDPreference: Equatable {
4242
let id: AnyHashable
4343
let bounds: Anchor<CGRect>
44+
45+
// `Anchor` is only conditionally `Equatable` since iOS 15.
46+
// If synthesized, the compiler doesn't see any issues and this leads to a runtime crash on earlier iOS versions.
47+
// That's why this is written here explicitly.
48+
public static func == (lhs: IDPreference, rhs: IDPreference) -> Bool {
49+
if #available(iOS 15, *) {
50+
return lhs.id == rhs.id && lhs.bounds == rhs.bounds
51+
} else {
52+
return lhs.id == rhs.id
53+
}
54+
}
4455
}

0 commit comments

Comments
 (0)