$npx -y skills add dpearson2699/swift-ios-skills --skill appmigrationkitTransfer app data to or from other platforms using AppMigrationKit. Use when implementing system-orchestrated one-time migration between iOS and Android or another platform, building an AppMigrationExtension, packaging transportable resources with ResourcesArchiver, importing res
| 1 | # AppMigrationKit |
| 2 | |
| 3 | One-time cross-platform data transfer for app resources. Enables apps to |
| 4 | export data to or import data from another platform (for example, Android) |
| 5 | during device setup or onboarding. AppMigrationKit APIs are iOS 26.0+ / |
| 6 | iPadOS 26.0+; the data-container entitlement is iOS 26.1+ / iPadOS 26.1+ / |
| 7 | Mac Catalyst 26.1+. Swift 6.3. |
| 8 | |
| 9 | > **Beta-sensitive.** AppMigrationKit is new in iOS 26 and may change before GM. |
| 10 | > Re-check current Apple documentation before relying on specific API details. |
| 11 | |
| 12 | AppMigrationKit uses an app extension model. The system orchestrates the |
| 13 | transfer between devices. The app provides an extension conforming to export |
| 14 | and import protocols, and the system calls that extension at the appropriate |
| 15 | time. The app itself never manages the network connection between devices. |
| 16 | |
| 17 | ## Contents |
| 18 | |
| 19 | - [Architecture Overview](#architecture-overview) |
| 20 | - [Setup and Entitlements](#setup-and-entitlements) |
| 21 | - [App Migration Extension](#app-migration-extension) |
| 22 | - [Exporting Resources](#exporting-resources) |
| 23 | - [Importing Resources](#importing-resources) |
| 24 | - [Migration Status](#migration-status) |
| 25 | - [Progress Tracking](#progress-tracking) |
| 26 | - [Testing](#testing) |
| 27 | - [Common Mistakes](#common-mistakes) |
| 28 | - [Review Checklist](#review-checklist) |
| 29 | - [References](#references) |
| 30 | |
| 31 | ## Architecture Overview |
| 32 | |
| 33 | AppMigrationKit operates through three layers: |
| 34 | |
| 35 | 1. **App extension** -- An `AppMigrationExtension` conforming type that the |
| 36 | system invokes during migration. It handles data export and import. |
| 37 | 2. **System orchestration** -- The OS manages the device-to-device session, |
| 38 | transport, and scheduling. The extension does not control when it runs. |
| 39 | 3. **Containing app** -- After migration completes, the app checks |
| 40 | `MigrationStatus.importStatus` on first launch to determine whether |
| 41 | migration occurred and whether it succeeded. |
| 42 | |
| 43 | Key types: |
| 44 | |
| 45 | | Type | Role | |
| 46 | |---|---| |
| 47 | | `AppMigrationExtension` | Protocol for the app extension entry point | |
| 48 | | `ResourcesExportingWithOptions` | Protocol for exporting files via archiver | |
| 49 | | `ResourcesExporting` | Simplified export protocol (no custom options) | |
| 50 | | `ResourcesImporting` | Protocol for importing files on the destination | |
| 51 | | `ResourcesArchiver` | Streams files into the export archive | |
| 52 | | `MigrationDataContainer` | Access to the containing app's data directories | |
| 53 | | `MigrationStatus` | Check import result from the containing app | |
| 54 | | `MigrationPlatform` | Identifies the other device's platform (e.g., `.android`) | |
| 55 | | `MigrationAppIdentifier` | Identifies the source app by store and bundle ID | |
| 56 | | `AppMigrationTester` | Test-only actor for validating export/import logic | |
| 57 | |
| 58 | ## Setup and Entitlements |
| 59 | |
| 60 | ### Entitlement |
| 61 | |
| 62 | The app extension requires the `com.apple.developer.app-migration.data-container-access` |
| 63 | entitlement. Its value is a single-element string array containing the bundle |
| 64 | identifier of the containing app: |
| 65 | |
| 66 | ```xml |
| 67 | <key>com.apple.developer.app-migration.data-container-access</key> |
| 68 | <array> |
| 69 | <string>com.example.myapp</string> |
| 70 | </array> |
| 71 | ``` |
| 72 | |
| 73 | No other values are valid. This entitlement grants the extension read access |
| 74 | to the containing app's data container during export and write access during |
| 75 | import. The entitlement itself is available on iOS 26.1+, iPadOS 26.1+, |
| 76 | and Mac Catalyst 26.1+, even though the core AppMigrationKit APIs are |
| 77 | available on iOS 26.0+ and iPadOS 26.0+. |
| 78 | |
| 79 | ### Extension Target |
| 80 | |
| 81 | Add a new App Extension target to the Xcode project. The extension conforms |
| 82 | to one or more of the migration protocols (`ResourcesExportingWithOptions`, |
| 83 | `ResourcesExporting`, `ResourcesImporting`). |
| 84 | |
| 85 | ## App Migration Extension |
| 86 | |
| 87 | The extension entry point conforms to `AppMigrationExtension`. During |
| 88 | migration, the system prevents launching the containing app and its other |
| 89 | extensions to ensure exclusive data access. |
| 90 | |
| 91 | ### Accessing the Data Container |
| 92 | |
| 93 | The extension accesses the containing app's files through `appContainer`: |
| 94 | |
| 95 | ```swift |
| 96 | import AppMigrationKit |
| 97 | |
| 98 | struct MyMigrationExtension: ResourcesExporting { |
| 99 | var resourcesSizeEstimate: Int { estimateTotalExportSize() } |
| 100 | var resourcesVersion: String { "1.0" } |
| 101 | var resourcesCompressible: Bool { true } |
| 102 | |
| 103 | func exportResources( |
| 104 | to archiver: sending ResourcesArchiver, |
| 105 | request: MigrationRequest |
| 106 | ) async throws { |
| 107 | let container = appContainer |
| 108 | |
| 109 | // container.bundleIdentifier -- app's bundle ID |
| 110 | // container.containerRootDirectory -- root of the app container |
| 111 | // container.documentsDirectory -- Doc |