disk_kit_macos 1.1.0
disk_kit_macos: ^1.1.0 copied to clipboard
macOS platform implementation for DiskKit using native macOS APIs.
disk_kit_macos #
macOS implementation of the federated DiskKit Flutter plugin. Applications should depend on and import disk_kit; this package registers automatically.
The plugin uses Disk Arbitration for descriptions, notifications, mounting, unmounting, and ejecting. IOKit enumerates existing IOMedia objects for initial discovery. FileManager copies files and directories on a serial background queue. /usr/sbin/diskutil performs formatting using explicit process arguments without a shell.
Formatting supports exFAT, FAT32, both case-sensitive and case-insensitive APFS, and all four combinations of HFS+ case sensitivity and journaling. Both APFS variants require GPT for whole-disk formatting.
Requires macOS 12+, Flutter 3.27+, and Dart 3.6+. The plugin requires an application outside App Sandbox. Raw image writing and macOS installer preparation can request administrator authorization through system dialogs; other operations use the host privileges. No persistent privileged helper is installed. Formatting is limited to media identified as external. Operating system restrictions are returned as structured errors.
The native and Dart method/event channels are eu.byfox.disk_kit/methods and eu.byfox.disk_kit/disks. Native requests targeting the same containing whole disk are rejected while another DiskKit operation on it is pending.
See the public API guide and the example testing guide.
Installation media #
writeImage writes uncompressed IMG/hybrid ISO to a raw external whole disk, unmounting and claiming it through Disk Arbitration. A mount approval callback blocks remounting while it writes. Raw writing and read-back verification stream through native file descriptors. When access requires authorization, Authorization Services and authopen transfer only an existing device descriptor over a Unix socket. There is no separate privileged raw writer. Fresh IOKit registry IDs identify the current attachment.
createWindowsInstaller mounts ISO read-only through hdiutil, preflights the file tree, optionally splits an oversized installation WIM with caller-installed wimlib-imagex, and copies to MBR/FAT32 for UEFI. Ordinary copies are verified byte-for-byte when requested. Legacy BIOS and oversized ESD are unsupported.
createMacOSInstaller requires a full Apple installer app, verifies Apple signatures, and uses createinstallmedia with administrator authorization through AppleScript. Its phase telemetry uses an exclusively created root-owned temporary directory. It does not accept macOS ISO/DMG containers. The authorization prompt precedes formatting. Apple's tool has indeterminate progress and controls validation.
Progress is sent as mediaProgress callbacks on the existing method channel, correlated by an operation ID. No password is passed through Dart. See the public API guide for supported sources and limitations.
Development #
Run flutter pub get from the workspace root. Native filesystem tests can be run independently with sh tool/test_macos.sh; they only use temporary files and validate formatting arguments without launching a format operation.
Source and issues. Distributed under the MIT License.
Publisher: darkfox.pl.
Native dependency managers #
The package supports CocoaPods and Swift Package Manager. Its SwiftPM product is disk-kit-macos; the target imports FlutterFramework and links Disk Arbitration, IOKit, and Security. Current SwiftPM builds and native channel tests were verified using Flutter 3.47.5. CocoaPods remains available for applications using older supported Flutter versions.
The manifest follows the official Flutter plugin guide. Flutter generates the FlutterFramework dependency while integrating the consuming application; running swift build directly inside the published plugin is not the application integration test.