ITADN

invalidAVFileType error in URL+createTempURL.swift — UTType(mimeType:) called with UTI string instead of MIME type

#3782ClosedEliasGcf 创建于 2026-04-24
E
EliasGcfcommented
## Bug Description `createRecorder()` always fails with `TemporaryFileError.invalidAVFileType` because `URL.createTempURL(fileType: AVFileType)` passes a UTI identifier string to `UTType(mimeType:)`, which expects a MIME type. ## Steps to Reproduce 1. Create any `CameraVideoOutput` (with or without explicit `fileType`) 2. Call `createRecorder({})` 3. Error: `invalidAVFileType` Both `'mov'` and `'mp4'` file types trigger the bug. ## Root Cause In `ios/Extensions/URL+createTempURL.swift` (line 34-40): ```swift static func createTempURL(fileType: AVFileType) throws(TemporaryFileError) -> URL { let mimeType = fileType.rawValue guard let utFileType = UTType(mimeType: mimeType) else { throw TemporaryFileError.invalidAVFileType } return try createTempURL(fileType: utFileType) } ``` `AVFileType.rawValue` returns a **UTI identifier** (e.g. `"com.apple.quicktime-movie"` for `.mov`, `"public.mpeg-4"` for `.mp4`), not a MIME type (which would be `"video/quicktime"` or `"video/mp4"`). `UTType(mimeType:)` expects a MIME type string, so it returns `nil` for any UTI string. ## Suggested Fix Replace `UTType(mimeType:)` with the `UTType(_:)` initializer, which accepts UTI identifier strings: ```swift static func createTempURL(fileType: AVFileType) throws(TemporaryFileError) -> URL { let utiString = fileType.rawValue guard let utFileType = UTType(utiString) else { throw TemporaryFileError.invalidAVFileType } return try createTempURL(fileType: utFileType) } ``` ## Environment - react-native-vision-camera: 5.0.6 - iOS 18 - Xcode 16
关闭于 2026-04-24 1 条评论