Android: `withMediaPicker(type: .library)` returns an uncopied `content://` URI that Skip Fuse apps cannot read
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 78/100
Research direction
Read the .library and multi-select branches in MediaPicker.swift, then compare them with the copy branch in DocumentPicker.swift. Trace how the picker result URI is opened and how the cache file URL is returned. Done when Data(contentsOf:) can read the selected image in a Skip Fuse Android app; the issue names no test to run.
Written by the indexing model from the issue text.
Description
skip-kit version: 1.1.5 (same code in 1.0.0)
What happens. On Android, the .library branch of MediaPicker.swift passes the photo picker's result straight
through:
selectedImageURL.wrappedValue = URL(platformValue: java.net.URI.create(uri.toString()))
That is a content://media/picker_get_content/… URI. In a Skip Fuse app, Foundation is native, and native
Data(contentsOf:) has no content-resolver path. So reading the picked image fails, and uploading or processing it
is impossible without the app writing its own ContentResolver bridge. On iOS the same API returns a file:// URL,
so cross-platform code that works on iOS silently fails on Android.
Expected. The same contract as DocumentPicker. It already opens the URI through context.contentResolver,
copies it into cacheDir under a safe name and returns a file:// URL (DocumentPicker.swift, the copy branch).
Doing the same in the .library (and multi-select) branches of MediaPicker would make the returned URL readable
from native Swift on both platforms.
Steps to reproduce.
- In a Skip Fuse app, attach
.withMediaPicker(type: .library, isPresented:, selectedImageURL:). - Pick a photo on an Android device (Pixel 5, Android 14, system photo picker).
try Data(contentsOf: selectedImageURL)throws; the URL's scheme iscontent.
Workaround we ship. A per-app adapter: native Swift, AnyDynamicObject calls to getContentResolver(),
openInputStream, FileOutputStream and android.os.FileUtils.copy, copying into the cache directory before the
URL is used. We would like to delete it once the picker copies.
- Dominant language
- Swift
- Stars
- 11
- Forks
- 11
- Avg merge
- 10h 17m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from skiptools/skip-kit
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in skiptools/skip-kit
Similar issues
-
AndroidAssetManager(env:peer:) in AssetURLProtocol.swift doesn't compile for Android on the Swift nightlyPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
erkamyaman/unslop-anything#579 ·
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
erkamyaman/rust-anything#1311 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug priority:low status:queued
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day