#Tauri 2.0 - open dialog iOS

1 messages · Page 1 of 1 (latest)

winter vector
#

I am trying to use the plugin-dialog with iOS dev. The following code opens the image chooser (the photos app) in the simulator, however, i want to have the dialog choose a file from the Files app. In this case a CSV file. Is there a special syntax needed for iOS? I looked through the plugin-dialog repo under iOS folder but my understanding of Swift code is admittedly limited.

import { open } from '@tauri-apps/plugin-dialog';

const file = await open({
  multiple: false,
  directory: false,
  filters: [{ name: 'CSV', extensions: ['csv'] }]
});
#

I tried this from the documention. However it errors:

import { open } from '@tauri-apps/plugin-dialog';
import { appDir } from '@tauri-apps/api/path';
// Open a selection dialog for directories
const selected = await open({
  directory: true,
  multiple: true,
  defaultPath: await appDir(),
});

Error: Module '"@tauri-apps/api/path"' has no exported member 'appDir'.

#

I don't want to select a directory but was thinking maybe because of permissons etc, iOS wanted a default path.

#

I'm thinking it could be due to permissions or how the plugin is interpreting the file type filters.

#

Do in need to modify the info.plist file?

<key>NSDocumentsFolderUsageDescription</key>
<string>We need access to your documents folder to select files.</string>
#

I hate to edit the info.plist as it seems to be auto generated by tauri ios init

#

My capabilities/default.json

{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default",
  "description": "Capability for the main window",
  "windows": [
    "main"
  ],
  "permissions": [
    "store:default",
    "store:allow-get",
    "store:allow-set",
    "store:allow-save",
    "store:allow-load",
    "store:allow-clear",
    "store:allow-delete",
    "store:allow-has",
    "store:allow-keys",
    "store:allow-length",
    "store:allow-reset",
    "store:allow-values",
    "path:default",
    "event:default",
    "window:default",
    "app:default",
    "image:default",
    "resources:default",
    "menu:default",
    "tray:default",
    "shell:allow-open",
    "fs:default",
    "dialog:default"
  ]
}

Do i need a $schema for iOS too? Is the dialog:default permission insufficient?

winter vector
#

I tried the properties property. Still only opens photo picker
properties: [{ mimeTypes: ['text/csv'] }],

winter vector
#

So, stuck trying to figure out how the user can supply a CSV file to the app on iOS. Maybe the dialog open method is the wrong approach.

kind badge
# winter vector So, stuck trying to figure out how the user can supply a CSV file to the app on ...

Did you get the dialog to show up though? I'm doing this

  const handleClick = async () => {
    // Open a selection dialog for directories
    const selectedDir = await open({
      directory: true,
      multiple: false,

      // defaultPath: BaseDirectory,
      title: "Select Workspace directory",
    });

    setWorkspacePath(selectedDir);
  };

which works on desktop, but doesn't in the iOS simulator or the device. Clicking on the button does nothing, no dialogs are shown.

winter vector
#

What come up for me it the photo picker dialog. It returns the photo selected. But I want a file picker instead. But, yes on iOS I do get a dialing, just not the one I want.

kind badge
#

Weird, i don’t even get the popup

winter vector
#

Try to use the manual install method for plugins. I found that the one line installation did not work at all for most plugins. Might help if you haven’t tried already

kind badge
#

it does open up fine on desktop though, so it seems like the plugin works?

winter vector
#

Good point. I’ll keep working on it and will post my findings. So far, I have not heard of or seen a working example from anyone. 🫤

winter vector
#

@empty valley just posted this in general. #general message

Not all apis are (fully) implemented yet.

Maybe that is the answer? Save us beating our heads on our keyboards for days trying to make it work. 😆

#

It is still in beta so we might have to wait a bit longer.

empty valley
winter vector
#

@empty valley will do! Thanks. I’ll try to be as thorough as possible

winter vector
empty valley
#

thank you!

winter vector
# empty valley thank you!

Thank you for looking into it! Tauri is a huge project and I appreciate the work the team is doing on it. When Daniel first mentioned the project I got excited to see an Electron alternative. Adding mobile is a huge undertaking. For a small dev like myself who writes software for niche use (all for free), Tauri is just the perfect way for me to use a single codebase to build these apps even if only for a handful of users. Cheers!