appmigrationkit

Transfer 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 resources on the destin

By dpearson2699 · 2,609 installs

npx skills add dpearson2699/swift-ios-skills --skill appmigrationkit

Source repository · Upstream listing

AppMigrationKit One time cross platform data transfer for app resources. Enables apps to export data to or import data from another platform (for example, Android) during device setup or onboarding. AppMigrationKit APIs are iOS 26.0+ / iPadOS 26.0+; the data container entitlement is iOS 26.1+ / iPadOS 26.1+ / Mac Catalyst 26.1+. Swift 6.3. Beta sensitive. AppMigrationKit is new in iOS 26 and may change before GM. Re check current Apple documentation before relying on specific API details. AppMigrationKit uses an app extension model. The system orchestrates the transfer between devices. The app provides an extension conforming to export and import protocols, and the system calls that extension at the appropriate time. The app itself never manages the network connection between devices. Contents [Architecture Overview]( architecture overview) [Setup and Entitlements]( setup and entitlements) [App Migration Extension]( app migration extension) [Exporting Resources]( exporting resources) [Importing Resources]( importing resources) [Migration Status]( migration status) [Progress Tracking]( progress tracking) [Testing]( testing) [Common Mistakes]( common mistakes) [Review Checklist]( review checklist) [References]( references) Architecture Overview AppMigrationKit operates through three layers: 1. App extension An AppMigrationExtension conforming type that the system invokes during migration. It handles data export and import. 2. System orchestration The OS manages the device to device session, transport, and scheduling. The extension does not control when it runs. 3. Containing app After migration completes, the app checks MigrationStatus.importStatus on first launch to determine whether migration occurred and whether it succeeded. Key types: Type Role AppMigrationExtension Protocol for the app extension entry point ResourcesExportingWithOptions Protocol for exporting files via archiver ResourcesExporting Simplified export protocol (no custom options) ResourcesImporting Protocol for importing files on the destination ResourcesArchiver Streams files into the export archive MigrationDataContainer Access to the containing app's data directories MigrationStatus Check import result from the containing app MigrationPlatform Identifies the other device's platform (e.g., .android ) MigrationAppIdentifier Identifies the source app by store and bundle ID AppMigrationTester Test only actor for validating export/import logic Setup and Entitlements Entitlement The app extension requires the com.apple.developer.app migration.data container access entitlement. Its value is a single element string array containing the bundle identifier of the containing app: No other values are valid. This entitlement grants the extension read access to the containing app's data container during export and write access during import. The entitlement itself is available on iOS 26.1+, iPadOS 26.1+, and Mac Catalyst 26.1+, even though the core AppMigrationKit APIs are available on iOS 26.0+ and iPadOS 26.0+. Extension Target Add a new App Extension target to the Xcode project. The extension conforms to one or more of the migration protocols ( ResourcesExportingWithOptions , ResourcesExporting , ResourcesImporting ). App Migration Extension The extension entry point conforms to AppMigrationExtension . During migration, the system prevents launching the containing app and its other extensions to ensure exclusive data access. Accessing the Data Container The extension accesses the containing app's files through appContainer : MigrationDataContainer provides containerRootDirectory , documentsDirectory , and applicationSupportDirectory as URL values pointing into the containing app's sandbox. Exporting Resources Conform to ResourcesExportingWithOptions (or ResourcesExporting for no custom options) to package files for transfer. The system calls exportResources(to:request:) with a ResourcesArchiver and a MigrationRequestWithOptions . Declaring Export Properties resourcesSizeEstimate Estimated total bytes. The system uses this for progress UI and free space checks. resourcesVersion Format version string. The import side receives this to handle versioned data formats. resourcesCompressible When true , the archiver may compress files during transport. Implementing Export The archiver streams files incrementally. Call appendItem(at:pathInArchive:) repeatedly as each resource is ready. The system may terminate the extension if it appears hung, so avoid long gaps between append calls. Cancellation ResourcesArchiver handles task cancellation automatically by throwing cancellation errors. Do not catch these errors doing so causes the system to kill the extension. Migration Platform MigrationRequestWithOptions exposes destinationPlatform as a MigrationPlatform value. Use this to tailor exported data: MigrationPlatform provides .android as a static constant. Custom platforms can be created with MigrationPlatform("customPlatform") . Importing Resources Conform to ResourcesImporting to receive transferred files on the destination device. The system calls importResources(at:request:) after app installation but before the app is launchable. Error Handling During Import On import error, the system clears the containing app's data container to prevent partial state. However, app group containers are not cleared. The import implementation should clear any app group containers before writing imported content: Source App Identifier ResourcesImportRequest provides sourceAppIdentifier as a MigrationAppIdentifier with three properties: platform The source device's platform (e.g., .android ) bundleIdentifier The source app's bundle identifier storeIdentifier The app store (e.g., .googlePlay ) Migration Status After migration completes, the containing app checks the result on first launch: MigrationStatus.importStatus is nil if no migration occurred. Call clearImportStatus() after handling the result to prevent showing the notification on subsequent launches. The enum has two cases: .success and .failure(any Error) . Progress Tracking The import side exposes a Progress object via resourcesImportProgress . The system uses this to display transfer progress to the user. Update completedUnitCount incrementally during import: Testing AppMigrationTester is a test only actor for validating migration logic in unit tests hosted by the containing app. Do not use it in production. DeviceToDeviceExportProperties on the result exposes uncompressedBytes , compressedBytes (nil if not compressible), sizeEstimate , and version . See [references/appmigrationkit patterns.md](references/appmigrationkit patterns.md) for additional test patterns. Common Mistakes DON'T: Catch cancellation errors from ResourcesArchiver DON'T: Leave long gaps between archiver append calls DON'T: Convert files to intermediate format during export DON'T: Ignore app group containers during import error recovery DON'T: Forget to clear import status after handling it Review Checklist [ ] Extension target added with com.apple.developer.app migration.data container access entitlement [ ] Entitlement array contains exactly one string: the containing app's bundle identifier [ ] Extension conforms to ResourcesExportingWithOptions or ResourcesExporting for export [ ] Extension conforms to ResourcesImporting for import [ ] resourcesSizeEstimate returns a reasonable byte estimate [ ] resourcesVersion is set and will be checked on import for format compatibility [ ] Export calls appendItem incrementally without long pauses [ ] Cancellation errors from ResourcesArchiver are not caught [ ] Import clears app group containers before writing new data [ ] Containing app checks MigrationStatus.importStatus on first launch [ ] clearImportStatus() called after handling the migration result [ ] AppMigrationTester used in unit tests to validate export and import [ ] Files are exported as is without intermediate format conversion on the export side [ ] sourceVersion from import request used to handle versioned data formats References Extended patterns (combined extension, versioned migration, file enumeration, error recovery): [references/appmigrationkit patterns.md](references/appmigrationkit patterns.md) [AppMigrationKit framework](https://sosumi.ai/documentation/appmigrationkit) [AppMigrationExtension](https://sosumi.ai/documentation/appmigrationkit/appmigrationextension) [ResourcesExportingWithOptions](https://sosumi.ai/documentation/appmigrationkit/resourcesexportingwithoptions) [ResourcesImporting](https://sosumi.ai/documentation/appmigrationkit/resourcesimporting) [ResourcesArchiver](https://sosumi.ai/documentation/appmigrationkit/resourcesarchiver) [MigrationStatus](https://sosumi.ai/documentation/appmigrationkit/migrationstatus) [MigrationDataContainer](https://sosumi.ai/documentation/appmigrationkit/migrationdatacontainer) [AppMigrationTester](https://sosumi.ai/documentation/appmigrationkit/appmigrationtester) [Data container entitlement](https://sosumi.ai/documentation/bundleresources/entitlements/com.apple.developer.app migration.data container access)