Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Using plugin-dialog and plugin-fs to write file on iOS is ineffective. #2089

Open
nashaofu opened this issue Nov 23, 2024 · 4 comments · May be fixed by #2424
Open

[bug] Using plugin-dialog and plugin-fs to write file on iOS is ineffective. #2089

nashaofu opened this issue Nov 23, 2024 · 4 comments · May be fixed by #2424
Labels
bug Something isn't working platform: ios iOS specific issues plugin: dialog plugin: fs Includes former "fs-extra" and "fs-watch" plugins question Further information is requested

Comments

@nashaofu
Copy link
Contributor

Replicate the code:https://github.com/shell360/tauri-issue
The replication steps:

  1. git clone https://github.com/shell360/tauri-issue.git
  2. cd tauri-issue && pnpm install
  3. run pnpm tauri ios dev,And select the iOS simulator.
  4. click save file button
  5. 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
@nashaofu nashaofu changed the title [bug] Using plugin-open and plugin-fs to write files on iOS is ineffective. [bug] Using plugin-open and plugin-fs to write file on iOS is ineffective. Nov 23, 2024
@nashaofu nashaofu changed the title [bug] Using plugin-open and plugin-fs to write file on iOS is ineffective. [bug] Using plugin-dialog and plugin-fs to write file on iOS is ineffective. Nov 23, 2024
@FabianLars FabianLars added bug Something isn't working question Further information is requested plugin: dialog plugin: fs Includes former "fs-extra" and "fs-watch" plugins platform: ios iOS specific issues labels Nov 23, 2024
@nashaofu
Copy link
Contributor Author

Does everyone help look at this problem?

@wxiaoyun
Copy link

wxiaoyun commented Feb 1, 2025

Here is the bug reproduction in case anyone is interested in addressing this: https://github.com/wxiaoyun/tauri-ios-fs-bug-reproduction

@nashaofu
Copy link
Contributor Author

Have you solved this problem? @wxiaoyun

@wxiaoyun
Copy link

wxiaoyun commented Feb 15, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform: ios iOS specific issues plugin: dialog plugin: fs Includes former "fs-extra" and "fs-watch" plugins question Further information is requested
Projects
None yet
3 participants