Skip to content

Commit e63cc8c

Browse files
helenkwokclaude
andcommitted
fix(example): strip file:// prefix from DocumentPicker URI
Stage B device measurement surfaced a bug in the native module: ExpoLitertLmModule.swift:96 calls `URL(fileURLWithPath: modelPath)`, which interprets its arg as a literal POSIX path. When DocumentPicker.getDocumentAsync({copyToCacheDirectory: false}) returns a file:// URI string, the constructed URL has a malformed `.path` that FileManager.fileExists(atPath:) returns false for — surfacing in JS as "LiteRT-LM model file not found". This commit applies the workaround in the example so device measurement can complete: strip `file://` from the picker URI before setModelPath. Metro hot-reloads; no rebuild needed. The proper fix in the native module — accept either a POSIX path or a file:// URL — lands in 0.2.0-rc.0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8cb580b commit e63cc8c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

example/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ export default function App() {
8282
});
8383
if (res.canceled) return;
8484
const uri = res.assets?.[0]?.uri;
85-
if (uri) setModelPath(uri);
85+
if (uri) {
86+
// Native module's URL(fileURLWithPath:) treats its arg as POSIX path,
87+
// so a file:// scheme prefix breaks fileExists. Strip it for Stage B.
88+
// Phase 14-09 follow-up: native module should accept either form.
89+
setModelPath(uri.startsWith('file://') ? uri.replace(/^file:\/\//, '') : uri);
90+
}
8691
};
8792

8893
const startPolling = () => {

0 commit comments

Comments
 (0)