fix(ios): build fail due to an unwrapped value (#4101)

* fix: ios build crash due to AVMediaSelectionGroup not being unwrapped

* fix: use shorthand optional binding

* fix: disable swiftlint shorthand_optional_binding for guard let

* fix(ios): use guard do catch

Co-authored-by: Krzysztof Moch <krzysmoch.programs@gmail.com>

---------

Co-authored-by: Krzysztof Moch <krzysmoch.programs@gmail.com>
This commit is contained in:
Faustino Kialungila 2024-08-21 10:26:32 +02:00 committed by GitHub
parent 41e2bed6b3
commit 0a1085ce03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,7 +9,15 @@ enum RCTVideoAssetsUtils {
for mediaCharacteristic: AVMediaCharacteristic
) async -> AVMediaSelectionGroup? {
if #available(iOS 15, tvOS 15, visionOS 1.0, *) {
return try? await asset?.loadMediaSelectionGroup(for: mediaCharacteristic)
do {
guard let asset else {
return nil
}
return try await asset.loadMediaSelectionGroup(for: mediaCharacteristic)
} catch {
return nil
}
} else {
#if !os(visionOS)
return asset?.mediaSelectionGroup(forMediaCharacteristic: mediaCharacteristic)