@gbyte/tauri-plugin-ios-photos

中文文档
0.3.0发布于 2025/12/31MITTypeScriptESM + CJS近 30 天下载 2130

Access iOS user device photo library.

原始使用文档
文档目录10 节
  1. Features
  2. Requirements
  3. iOS Permissions
  4. Installation
  5. Usage (Conceptual Example)
  6. About Image Path Access
  7. Authorization Status
  8. Todos / Roadmap
  9. Notes
  10. License

Tauri Plugin iOS Photos

A Tauri plugin for accessing and managing iOS Photos albums and assets using the native Photos framework.

This plugin allows Tauri applications to request photo permissions, read albums, access photos, and perform basic album/photo management on iOS devices.

⚠️ iOS only. This plugin relies on Apple Photos APIs and is not available on other platforms.


Features

  • Request and check photo library authorization
  • List user photo albums
  • Access photos from albums
  • Filter albums
  • Check album permission
  • Create and remove albums
  • Create, access, and delete photos

Requirements

  • Tauri 2.x (or compatible version)
  • Xcode with iOS SDK
  • Proper Photo Library permissions configured in Info.plist

iOS Permissions

This plugin requires access to the user’s photo library.

Make sure the following keys are added to your iOS Info.plist:

<key>NSPhotoLibraryUsageDescription</key>
<string>Allow access to your photo library</string>

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Allow saving photos to your photo library</string>

Installation

pnpm add @gbyte/tauri-plugin-ios-photos
# or
npm install @gbyte/tauri-plugin-ios-photos
# or
yarn add @gbyte/tauri-plugin-ios-photos

Add the plugin to your Tauri project's Cargo.toml:

[dependencies]
tauri-plugin-ios-photos = "0.3"

Or use cargo add tauri-plugin-ios-photos.

Configure the plugin permissions in your capabilities/default.json:

{
  "permissions": [
    "ios-photos:default"
  ]
}

Register the plugin in your Tauri app:

fn main() {
    tauri::Builder::default()
        .plugin(tauri_plugin_ios_photos::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Usage (Conceptual Example)

import {
  requestPhotosAuth,
  PhotosAuthorizationStatus,
  requestAlbums,
  PHAssetCollectionType,
  PHAssetCollectionSubtype
} from '@gbyte/tauri-plugin-ios-photos'

let photoAuth = ''
let albums = []

requestPhotosAuth()
  .then((status) => {
    switch (status) {
      case PhotosAuthorizationStatus.authorized:
        photoAuth = 'authorized'
        break
      case PhotosAuthorizationStatus.denied:
        photoAuth = 'denied'
        break
      case PhotosAuthorizationStatus.limited:
        photoAuth = 'limited'
        break
      case PhotosAuthorizationStatus.restricted:
        photoAuth = 'restricted'
        break
      case PhotosAuthorizationStatus.notDetermined:
        photoAuth = 'notDetermined'
        break
    }
  })
  .then(() => {
    requestAlbums({
      with: PHAssetCollectionType.smartAlbum,
      subtype: PHAssetCollectionSubtype.albumRegular
    }).then((value) => {
      albums = value
    })
  })


About Image Path Access

The image paths returned by this plugin are local file paths, typically pointing to internal iOS sandbox locations.

In Tauri (especially on iOS / WebView environments), these local paths cannot be accessed directly by the frontend (e.g. via file:// or raw filesystem paths). This is due to WebView security and sandbox restrictions.

Before using these images in the frontend, you must expose them through a Tauri custom protocol (URI scheme) so they can be accessed as normal URLs.

Recommended approach:

  1. Register a custom URI scheme in Tauri (for example, temp://)

  2. When the frontend requests temp://:

  • Tauri reads the corresponding local file

  • Returns the binary data with the correct MIME type

  1. The frontend can then use the URL normally (e.g. )

⚠️ Notes:

  • This plugin does not automatically convert local paths into accessible URLs

  • Implementing the custom protocol is the responsibility of the application

  • For security reasons, it is recommended to restrict the accessible path scope


Authorization Status

Possible authorization states:

  • notDetermined
  • restricted
  • denied
  • authorized
  • limited

The plugin exposes APIs to query and react to these states.


Todos / Roadmap

  • Request access authorization
  • Check authorization type
  • List user device albums
  • Get photos from album
  • Filter album
  • Check album permission
  • Access photo
  • Create album
  • Create photo
  • Remove album
  • Remove photo
  • Delete photo
  • Documentation improvements
  • Example project
  • Error handling standardization

Notes

  • All photo operations follow iOS privacy rules.
  • Some actions may fail silently if permission is limited.
  • Album and photo identifiers are system-generated.

License

MIT

版本与发布记录

@gbyte/tauri-plugin-ios-photos 共发布 3 个版本,首次发布于 2025/12/24;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.3.0latest2025/12/3110 个月前
0.2.02025/12/2910 个月前
0.1.02025/12/2410 个月前

关于 @gbyte/tauri-plugin-ios-photos 的常见问题

@gbyte/tauri-plugin-ios-photos 是什么?

Access iOS user device photo library.

如何安装 @gbyte/tauri-plugin-ios-photos?

在项目目录运行 npm install @gbyte/tauri-plugin-ios-photos,或使用 pnpm add / yarn add / bun add。

@gbyte/tauri-plugin-ios-photos 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gbyte/tauri-plugin-ios-photos 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gbyte/tauri-plugin-ios-photos 可以商用吗?

@gbyte/tauri-plugin-ios-photos 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gbyte/tauri-plugin-ios-photos 的下载量有多少?

根据 npm 官方下载统计,@gbyte/tauri-plugin-ios-photos 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,130 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gbyte/tauri-plugin-ios-photos 还在维护吗?

最新版本 0.3.0 发布于 2025/12/31(10 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2025/12/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。