tauri-plugin-ios-bookmark
iOS security-scoped bookmark plugin for Tauri 2.
This plugin provides a native bridge for opening files from the iOS Files app, creating persistent security-scoped bookmarks, reading bookmarked files later, and forgetting saved bookmarks.
This crate is intended for Tauri 2 mobile apps that target iOS. The Rust crate registers the native plugin, while the guest JavaScript API exposes a small command surface for your frontend.
Features
pickAndBookmark: presentsUIDocumentPickerViewController, reads the file, and returns a bookmark identifier plus file metadatareadByBookmark: resolves a previously saved bookmark and reads the file againforgetBookmark: removes a stored bookmark
Package Layout
src/: Rust plugin entrypoints and mobile bridgeios/: Swift implementation for the iOS native pluginguest-js/: TypeScript guest API entrypointpermissions/: default Tauri permission definitions
Install
Add the Rust crate to your Tauri app:
Install the guest JavaScript API in your frontend package:
The guest package expects @tauri-apps/api from your Tauri application.
Rust Setup
Register the plugin in your Tauri builder:
JavaScript Usage
The guest API exposes three commands:
import {
forgetBookmark,
pickAndBookmark,
readByBookmark,
} from 'tauri-plugin-ios-bookmark-api'
const picked = await pickAndBookmark()
const targetedPick = await pickAndBookmark({
targetPath: '/docs/related.md',
})
console.log(picked.bookmarkId)
console.log(picked.fileName)
console.log(picked.filePath)
console.log(picked.content)
console.log(targetedPick.bookmarkId)
const reread = await readByBookmark(picked.bookmarkId)
console.log(reread.fileName)
console.log(reread.content)
await forgetBookmark(picked.bookmarkId)
pickAndBookmark() returns:
type PickBookmarkRequest = {
targetPath?: string
suggestedFileName?: string
}
type PickResult = {
bookmarkId: string
fileName: string
filePath?: string
content: string
}
When targetPath is supplied, the plugin performs exact-file validation after the user picks a file. If the selected file does not match the requested target, the command rejects instead of creating a bookmark for the wrong file.
readByBookmark() returns:
type ReadResult = {
fileName: string
content: string
}
Permissions
The default permission set enables all plugin commands.
Available permissions are documented in
permissions/autogenerated/reference.md and include:
ios-bookmark:allow-pick-and-bookmarkios-bookmark:allow-read-by-bookmarkios-bookmark:allow-forget-bookmark
Platform Notes
- This plugin is iOS-only.
- The file picker is backed by
UIDocumentPickerViewController. - If
targetPathis provided, the plugin uses it as best-effort picker context and enforces exact-file validation after selection. - Bookmarks are intended for persistent access to user-selected files.
- On unsupported platforms, initialization returns an unsupported error path.