flutter_secure_storage_darwin

0.4.3

Apple (ios and macos) implementation of flutter_secure_storage

Download archive

Readme

flutter_secure_storage_darwin

This is the platform-specific implementation of flutter_secure_storage for iOS macOS.

Features

  • Secure storage using the Keychain API.
  • Fully integrated with iOS and macOS security features.

Installation

Add the dependency in your pubspec.yaml and run flutter pub get.

Configuration

You also need to add Keychain Sharing as capability to your iOS or macOS runner. To achieve this, please add the following in both your (ios/macos)/Runner/DebugProfile.entitlements and (ios/macos)/Runner/Release.entitlements.

<key>keychain-access-groups</key>
<array/>

If you have set your application up to use App Groups then you will need to add the name of the App Group to the keychain-access-groups argument above. Failure to do so will result in values appearing to be written successfully but never actually being written at all. For example if your app has an App Group named "aoeu" then your value for above would instead read:

<key>keychain-access-groups</key>
<array>
	<string>$(AppIdentifierPrefix)aoeu</string>
</array>

If you are configuring this value through XCode then the string you set in the Keychain Sharing section would simply read "aoeu" with XCode appending the $(AppIdentifierPrefix) when it saves the configuration.

macOS: Keychain Sharing requires provisioning

Adding keychain-access-groups enables Keychain Sharing, which requires a provisioning profile. On a free (non-Program) Apple Developer account, Xcode responds by embedding a machine-specific development provisioning profile, so the built app will only launch on the Mac that built it, and can't be distributed to other Macs (for example as a signed .app/.dmg outside the App Store).

If your app doesn't actually need Keychain Sharing (no App Group, no sharing items with another app of yours), you can avoid the entitlement entirely by disabling the data protection keychain on macOS instead:

final storage = Platform.isMacOS
    ? const FlutterSecureStorage(
        mOptions: MacOsOptions(usesDataProtectionKeychain: false),
      )
    : const FlutterSecureStorage();

This falls back to the legacy (non-data-protection) Keychain, which doesn't require keychain-access-groups or a provisioning profile.

Usage

Refer to the main flutter_secure_storage README for common usage instructions.

License

This project is licensed under the BSD 3 License. See the LICENSE file for details.

Changelog

Changelog

0.4.3 (2026-09-16)

Bug Fixes

  • darwin: find keychain items across accessibility levels (#1269) (9ae0e42)

0.4.2 (2026-09-11)

Bug Fixes

  • darwin: skip synchronizable keychain queries when the data protection keychain is off (0606cb4)

0.4.1

  • Fixed items written by versions prior to 0.3.0 becoming unreadable (and subsequent writes failing with errSecDuplicateItem) when no accessControlFlags are set. The 0.3.0 fix for kSecAttrSynchronizable being dropped caused read, readAll and containsKey to stop querying the legacy kSecAttrAccessControl storage envelope that those items were written under; they now fall back to it automatically. (#1158)

0.4.0

  • Raised minimum iOS deployment target from 12.0 to 13.0 to fix Swift compiler errors when building with Swift Package Manager. CryptoKit (used for Secure Enclave support) requires iOS 13.0+.

0.3.2

  • Fixed secStoreAvailabilitySink not being called when protected data availability changes.
  • Fixed kSecUseDataProtectionKeychain being added to Keychain queries unconditionally; it is now only set when useDataProtectionKeychain is explicitly enabled.

0.3.1

  • Fixed iOS build by updating availability annotation for Secure Enclave methods from iOS 11.3 to iOS 13.0.

0.3.0

  • Added useSecureEnclave support for iOS and macOS to store encryption keys in the device's Secure Enclave for hardware-backed security.
  • Use shared LAContext to reuse biometric authentication across Secure Enclave operations, avoiding double authentication prompts.
  • Secure Enclave keys now use hardcoded .privateKeyUsage access control, preventing "ACL operation is not allowed" errors.

Fixes:

  • Fixed kSecAttrSynchronizable being silently dropped when no access control flags are set.
  • Fixed readAll to correctly return Secure Enclave items.
  • Fixed macOS options keys alignment with iOS options.
  • Added plain-text fallback when a Secure Enclave wrapped key is missing.

0.2.0

  • Remove keys regardless of synchronizable state or accessibility constraints.

0.1.1

  • Fix warnings with Privacy Manifest

0.1.0

This package combines flutter_secure_storage_macos together with the ios part of flutter_secure_storage.

Other changes:

  • Code has been rebuild from the ground up
  • Lots of missing attributes have been added to the IOSOptions and MacOsOptions classes.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add flutter_secure_storage_darwin
pubspec.yaml
name: flutter_secure_storage_darwin
description: "Apple (ios and macos) implementation of flutter_secure_storage"
version: 0.4.3
homepage: https://github.com/juliansteenbakker/flutter_secure_storage
resolution: workspace

environment:
  sdk: '>=3.5.0 <4.0.0'
  flutter: '>=3.19.0'

dependencies:
  flutter:
    sdk: flutter
  plugin_platform_interface: ^2.1.8

dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:
  # This section identifies this Flutter project as a plugin project.
  # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
  # which should be registered in the plugin registry. This is required for
  # using method channels.
  # The Android 'package' specifies package in which the registered class is.
  # This is required for using method channels on Android.
  # The 'ffiPlugin' specifies that native code should be built and bundled.
  # This is required for using `dart:ffi`.
  # All these are used by the tooling to maintain consistency when
  # adding or updating assets for this project.
  plugin:
    platforms:
      ios:
        pluginClass: FlutterSecureStorageDarwinPlugin
        sharedDarwinSource: true
      macos:
        pluginClass: FlutterSecureStorageDarwinPlugin
        sharedDarwinSource: true

  # To add assets to your plugin package, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg
  #
  # For details regarding assets in packages, see
  # https://flutter.dev/to/asset-from-package
  #
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/to/resolution-aware-images

  # To add custom fonts to your plugin package, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts in packages, see
  # https://flutter.dev/to/font-from-package

Version history

VersionPublishedArchiveSHA-256
0.1.0On demandDownloadf226f2a5…951845
0.1.1On demandDownload81ef5abf…200051
0.2.0On demandDownload8878c251…69aee3
0.3.0On demandDownload3af15a3c…1fb320
0.3.1On demandDownload67cd1ff6…d73fcb
0.3.2Cached · Upstream SHA-256 matchedDownload82329fa5…7e8149
0.4.0On demandDownloadac6d76a7…c02ac0
0.4.1On demandDownloadd1021ca4…b2cabc
0.4.2On demandDownloadd0b136b1…2cc044
0.4.3Cached · Upstream SHA-256 matchedDownloada031ceac…797a21

Dependencies

flutter { "sdk": "flutter" }

plugin_platform_interface "^2.1.8"