From 0a1085ce03152d58d98da408dbe79e76fa5ebc1a Mon Sep 17 00:00:00 2001 From: Faustino Kialungila Date: Wed, 21 Aug 2024 10:26:32 +0200 Subject: [PATCH] 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 --------- Co-authored-by: Krzysztof Moch --- ios/Video/Features/RCTVideoUtils.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ios/Video/Features/RCTVideoUtils.swift b/ios/Video/Features/RCTVideoUtils.swift index c13c4d94..56b41d93 100644 --- a/ios/Video/Features/RCTVideoUtils.swift +++ b/ios/Video/Features/RCTVideoUtils.swift @@ -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)