[bug] Using plugin-dialog and plugin-fs to write file on iOS is ineffective.
Replicate the code:https://github.com/shell360/tauri-issue The replication steps:
-
git clone https://github.com/shell360/tauri-issue.git -
cd tauri-issue && pnpm install - run
pnpm tauri ios dev,And select the iOS simulator. - click
save filebutton - When checking the file in iOS file management, it was found that the content was not successfully written.
import { useCallback, useState } from 'react'
import { save, open } from '@tauri-apps/plugin-dialog'
import { writeFile, readFile } from '@tauri-apps/plugin-fs'
function App() {
const onSave = useCallback(async () => {
const path = await save()
if (!path) {
return
}
let encoder = new TextEncoder()
let data = encoder.encode('Hello World')
await writeFile(path, data) // The content was not successfully written.
}, [])
const onOpen = useCallback(async () => {
const path = await open()
if (!path) {
return
}
let content = await readFile(path)
console.log(content)
}, [])
return (
<main className="container">
<button onClick={onSave}>save file</button>
<button onClick={onOpen}>open file</button>
</main>
)
}
export default App
Does everyone help look at this problem?
Here is the bug reproduction in case anyone is interested in addressing this: https://github.com/wxiaoyun/tauri-ios-fs-bug-reproduction
Have you solved this problem? @wxiaoyun
Have you solved this problem? @wxiaoyun
I did not, currently I am not using the dialog plugin to save files. Just using plugin-fs directly.
Apologies for the lack of experience in native dev. When I try to save files directly to Downloads folder on iOS with plugin-fs, it seems the operation is rejected by the os even with the tauri capabilities configured with the corresponding write permissions. I am not sure if it has something to do with app sandboxing. Currently, I am working around this by downloading the files into the Documents folder of the application and expose the application Documents folder
Might be related to https://github.com/tauri-apps/tauri/issues/9190. I can only get write speeds of around 2.6 MB/s in debug mode, and 7.6 MB/s in release mode on a very recent M1 MacBook Pro.