Skip to content

EffortlessMetrics/SwiftMTP-dev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

83 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SwiftMTP

Swift-native Media Transfer Protocol stack with device quirks, modern SwiftUI implementation, and comprehensive verification suite.

A privacy-safe, evidence-gated MTP implementation for macOS and iOS with adaptive device handling and comprehensive device quirk support.

Release and roadmap status

Start Here for Implementation Sprints

Use this order when joining an active sprint:

  1. Read scope and acceptance criteria in Docs/ROADMAP.md.
  2. Confirm operating rules in Docs/SPRINT-PLAYBOOK.md.
  3. Run the Sprint Readiness Loop below.
  4. For transport/quirk changes, capture evidence with device-bringup.
  5. Update docs + CHANGELOG.md in the same PR.

Weekly sprint rhythm:

  • Monday: confirm scope, risks, and ready-state of sprint items.
  • Midweek: run checkpoint gates and resolve drift (test/docs/CI).
  • Friday: close or carry over items using DoD from the sprint playbook.

Sprint Readiness Loop

Use this command loop for implementation sprints:

# 1) Build + targeted checks while iterating
swift build --package-path SwiftMTPKit
swift test --package-path SwiftMTPKit --filter CoreTests

# 2) No-hardware smoke contract checks
./scripts/smoke.sh

# 3) Milestone/full gate before merge
./run-all-tests.sh

For real-device mode evidence capture:

./scripts/device-bringup.sh --mode mtp-unlocked --vid 0x18d1 --pid 0x4ee1

๐Ÿš€ Swift 6 Actor-Based Architecture

SwiftMTP is built with modern Swift 6 concurrency patterns:

Package Structure

  • SwiftMTPCore: Actor-isolated MTP protocol implementation with async/await
  • SwiftMTPTransportLibUSB: USB transport layer using libusb with fallback support
  • SwiftMTPIndex: SQLite-based device content indexing and snapshots
  • SwiftMTPSync: Mirror, sync, and diff operations with conflict resolution
  • SwiftMTPUI: Modern SwiftUI library using @Observable for reactive data flow
  • SwiftMTPQuirks: Device-specific tuning database with learned profiles
  • SwiftMTPObservability: Structured logging and performance monitoring
  • SwiftMTPStore: Persistence layer for device metadata and transfer journals
  • swiftmtp-cli: High-performance CLI tool for automation and power users
  • SwiftMTPApp: Standalone macOS GUI application for device management

Key Features

  • Privacy-First Design: Read-only collection mode with strict defaults
  • Device Quirks System: Learned profiles and static quirks for 50+ devices
  • Transfer Journaling: Resumable operations with automatic recovery
  • File Provider Integration: Native Finder integration on macOS (XPC service)
  • Benchmarking Suite: Performance profiling with p50/p95 metrics
  • Demo Mode: Simulated hardware profiles for development without physical devices

๐Ÿ›  Installation & Setup

Prerequisites

  • macOS Tahoe 26.0+ (macOS 2026, requires Apple Silicon or Intel Mac with Tahoe upgrade)

  • iOS 26.0+ (partial support: index, sync, and FileProvider operations; USB transport requires macOS host)

  • macOS 26.0+ / iOS 26.0+

  • Xcode 16.0+ with Swift 6 (6.2 recommended)

  • libusb installed via Homebrew: brew install libusb

Quick Start (GUI)

swift run --package-path SwiftMTPKit SwiftMTPApp

Quick Start (CLI)

swift run swiftmtp --help

Homebrew Installation

brew tap effortlessmetrics/swiftmtp
brew install swiftmtp

๐Ÿงช Verification & Testing

SwiftMTP utilizes a multi-layered verification strategy:

Full Verification Suite

./run-all-tests.sh

By default this runs:

  • SwiftMTPKit matrix (BDD + property + fuzz + integration + unit + e2e + snapshot + storybook)
  • Xcode app + unit + UI automation tests (set RUN_XCODE_UI_TESTS=0 to skip UI tests)

BDD Scenarios (CucumberSwift)

swift test --package-path SwiftMTPKit --filter BDDTests

Property-Based Testing (SwiftCheck)

swift test --package-path SwiftMTPKit --filter PropertyTests

Snapshot & Visual Regression

swift test --package-path SwiftMTPKit --filter SnapshotTests

Protocol Fuzzing

./SwiftMTPKit/run-fuzz.sh

Interactive Storybook (CLI)

./SwiftMTPKit/run-storybook.sh

๐Ÿ“ฑ Supported Devices

Device VID:PID Status Notes
Google Pixel 7 18d1:4ee1 โš ๏ธ Experimental Uses quirk-gated reset+reopen ladder on OpenSession I/O failures
OnePlus 3T 2a70:f003 โš ๏ธ Partial Probe/read stable; write-path tuning is still in-progress
Xiaomi Mi Note 2 2717:ff10 / 2717:ff40 โœ… Stable ff40 variant uses vendor-specific MTP interface matching
Samsung Galaxy S21 04e8:6860 โš ๏ธ Experimental Requires storage unlock prompt; class 0xff interface
Canon EOS (Rebel / R-class) 04a9:3139 ๐Ÿงช Experimental PTP over USB; camera must be in PTP/MTP mode
Nikon DSLR / Z-series 04b0:0410 ๐Ÿงช Experimental MTP/PTP mode required; NEF files need extended IO timeout

See Docs/SwiftMTP.docc/Devices/ for device-specific tuning guides.

Connected Device Lab (repeatable host workflow)

swift run swiftmtp device-lab connected --json

Artifacts are written under Docs/benchmarks/connected-lab/<timestamp>/ with per-device JSON reports.

Device Bring-Up Wrapper (mode evidence capture)

./scripts/device-bringup.sh --mode mtp-unlocked --vid 0x18d1 --pid 0x4ee1

This captures system_profiler USB data, swiftmtp usb-dump, and device-lab outputs under Docs/benchmarks/device-bringup/<timestamp>-<mode>/. See Docs/device-bringup.md for the (device ร— mode ร— operation) matrix.

๐ŸŽฎ Demo Mode & Simulation

Develop without physical hardware using simulated profiles:

# Enable demo mode
export SWIFTMTP_DEMO_MODE=1

# Select mock profile
export SWIFTMTP_MOCK_PROFILE=pixel7  # Options: pixel7, galaxy, iphone, canon

# Run CLI in demo mode
swift run swiftmtp probe

GUI users can toggle simulation via the Orange Play button in the toolbar.

๐Ÿ“Š Performance

Benchmark results from real devices:

Device Read Speed Write Speed Status
Google Pixel 7 N/A N/A Blocked on Tahoe 26 bulk-transfer timeout
OnePlus 3T N/A N/A Probe/read stable, large write path in progress
Samsung Galaxy S21 15.8 MB/s 12.4 MB/s Experimental but measurable

See Docs/benchmarks.md for detailed performance analysis.

๐Ÿ“– Development

Documentation

Building from Source

git clone https://github.com/effortlessmetrics/swiftmtp.git
cd swiftmtp
swift build

Building XCFramework (Required)

./scripts/build-libusb-xcframework.sh

DocC Preview

swift package --disable-sandbox preview-documentation --target SwiftMTPCore

Code Quality

swift-format -i -r Sources Tests
swift-format lint -r Sources Tests

๐Ÿ“ Project Structure

SwiftMTP/
โ”œโ”€โ”€ SwiftMTPKit/           # Swift Package root
โ”‚   โ”œโ”€โ”€ Sources/
โ”‚   โ”‚   โ”œโ”€โ”€ SwiftMTPCore/          # Core MTP protocol
โ”‚   โ”‚   โ”œโ”€โ”€ SwiftMTPTransportLibUSB/
โ”‚   โ”‚   โ”œโ”€โ”€ SwiftMTPIndex/         # SQLite indexing
โ”‚   โ”‚   โ”œโ”€โ”€ SwiftMTPSync/           # Mirror/sync
โ”‚   โ”‚   โ”œโ”€โ”€ SwiftMTPUI/             # SwiftUI views
โ”‚   โ”‚   โ”œโ”€โ”€ SwiftMTPQuirks/        # Device quirks
โ”‚   โ”‚   โ”œโ”€โ”€ SwiftMTPObservability/  # Logging
โ”‚   โ”‚   โ”œโ”€โ”€ SwiftMTPStore/         # Persistence
โ”‚   โ”‚   โ””โ”€โ”€ Tools/                 # CLI & App targets
โ”‚   โ””โ”€โ”€ Tests/                    # BDD, Property, Snapshot
โ”œโ”€โ”€ Docs/                  # Documentation
โ”‚   โ”œโ”€โ”€ SwiftMTP.docc/     # DocC documentation
โ”‚   โ””โ”€โ”€ benchmarks/       # Performance data
โ”œโ”€โ”€ Specs/                 # Schemas & quirks
โ”œโ”€โ”€ legal/                 # Licensing
โ””โ”€โ”€ scripts/              # Build & release tools

โš–๏ธ Licensing

SwiftMTP is dual-licensed:

  • AGPL-3.0 for open-source use
  • Commercial license for closed-source/App Store distribution

See legal/outbound/COMMERCIAL-LICENSE.md or contact git@effortlesssteven.com.

๐Ÿ† Acknowledgments

About

Swift-native MacOS and iOS MTP library

Resources

License

Stars

Watchers

Forks

Packages

No packages published