Skip to content

fix(ios): writeFile/stat in Directory.Temporary failing with OS-PLUG-FILE-0006 - #94

Merged
andredestro merged 2 commits into
mainfrom
fix/propagate-path-resolution-error
Oct 15, 2026
Merged

andredestro merged 2 commits into
mainfrom
fix/propagate-path-resolution-error

Conversation

@andredestro

@andredestro andredestro commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #90.

Problem

Since IONFilesystemLib 1.1.4, on iOS devices writeFile to a new file in Directory.Temporary fails with OS-PLUG-FILE-0006 (and stat on a missing file there returns 0006 instead of 0008). Root cause and fix are in the native lib: ionic-team/ion-ios-filesystem#20, released as 2.0.1.

Changes

  1. Pin IONFilesystemLib to exactly 2.0.1 (podspec '2.0.1', Package.swift exact: "2.0.1"). Exact instead of ~>/from so a plugin version maps to one native lib version, and a native regression can't reach apps through a fresh pod/SPM resolve without a plugin release (which is how 1.1.4 reached 8.1.2/8.1.3 users). See the discussion in fix: containment check rejects not-yet-created files in Directory.Temporary ion-ios-filesystem#20.
  2. Stop masking path resolution errors. FilesystemLocationResolver.resolveURL used try?, so any getFileURL failure was a bare Invalid '<path>' path. The code is unchanged (0006); the message now appends the underlying reason, e.g. Invalid 'x' path: Resolved path '...' is outside of directory '...'. This is what hid the cause of bug(ios): writeFile to Directory.Temporary fails with OS-PLUG-FILE-0006 since IONFilesystemLib 1.1.4 #90.

Verification (iPhone 16 Pro Max, iOS 27.0.1, example app)

The bug doesn't reproduce on the simulator (its tmp/ has no /private alias), so this was run on a device. The IONFilesystemLib binary in the app was checked (Mach-O UUID) against each build.

New file in Directory.Temporary lib 2.0.0 lib 2.0.1 (published, via this PR's podspec)
stat 0006 0008 (does not exist) ✅
writeFile 0006, nothing in tmp/ written, file present in tmp/ ✅
writeFile to ../../escape.txt blocked still blocked ✅

With 2.0.0, the new message shows the real cause: Invalid 'repro90-….txt' path: Resolved path '/private/var/mobile/…/tmp/repro90-….txt' is outside of directory '/var/mobile/…/tmp/'.

SPM: swift package resolve picks 2.0.1 and xcodebuild -scheme CapacitorFilesystem builds.

Note for upgrading apps

As with any native lib bump, apps with an existing Podfile.lock will get CocoaPods could not find compatible versions for pod "IONFilesystemLib" on npx cap sync until they run pod update IONFilesystemLib (or pod install --repo-update).

resolveURL used try?, so any failure (e.g. pathEscapesDirectory) was reported as a bare
'Invalid path' (OS-PLUG-FILE-0006). Keep the code, append the underlying reason.
2.0.1 fixes writing new files to Directory.Temporary (and stat on missing files there)
failing with OS-PLUG-FILE-0006 since the native containment check added in 1.1.4.

Pin the exact version so a plugin release maps to one native lib version and native
regressions can't reach apps through a fresh pod/SPM resolve.

Closes #90
@andredestro andredestro changed the title fix(ios): propagate underlying error on path resolution failure fix(ios): writeFile/stat in Directory.Temporary failing with OS-PLUG-FILE-0006 Oct 14, 2026

@OS-pedrogustavobilro OS-pedrogustavobilro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A reminder that we should update the cordova plugin with equivalent changes, and either release it for OutSystems. Or create a task for that so that it doesn't get lost and gets picked up whenever possible.

@andredestro
andredestro merged commit 71aaad1 into main Oct 15, 2026
8 checks passed
@andredestro
andredestro deleted the fix/propagate-path-resolution-error branch October 15, 2026 08:38
@andredestro

andredestro commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks! Created RMET-5536 to port this and release it for OutSystems.

capacitor-bot pushed a commit that referenced this pull request Oct 15, 2026
## [8.1.5](v8.1.4...v8.1.5) (2026-10-15)

### Bug Fixes

* **ios:** writeFile/stat in Directory.Temporary failing with OS-PLUG-FILE-0006 ([#94](#94)) ([71aaad1](71aaad1)), closes [#90](#90)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(ios): writeFile to Directory.Temporary fails with OS-PLUG-FILE-0006 since IONFilesystemLib 1.1.4

2 participants