UIKit to SwiftUI migration with AI agents: screen by screen, not a rewrite
Migrate one screen at a time. Host new SwiftUI screens in UIKit with UIHostingController (or UIHostingConfiguration for cells), wrap UIKit views SwiftUI still needs with UIViewRepresentable plus a Coordinator, and move to the SwiftUI App life cycle last, keeping your app delegate through UIApplicationDelegateAdaptor. Give the agent one interop skill and one UIKit skill.
Last updated:
This page is about getting a coding agent to move a working UIKit app to SwiftUI without a big-bang rewrite: which screen goes first, how the two frameworks talk to each other in the meantime, and when the app entry point changes. Building fresh SwiftUI screens is covered in Best Claude Code skills for SwiftUI; adapting layouts to resizable windows and iPhone Duo has its own guide.
What Apple documents: two bridges and a last step
Apple's UIKit integration page describes the migration surface in two directions: hosting controllers add SwiftUI views to UIKit interfaces, and representable objects wrap UIKit views and view controllers for SwiftUI. That is what makes screen-by-screen migration possible.
SwiftUI inside UIKit. UIHostingController is "a UIKit view controller that manages a SwiftUI view hierarchy." You create it with a root SwiftUI view, then present it or embed it as a child view controller. For cells, UIHostingConfiguration hosts SwiftUI in a
UITableViewCellorUICollectionViewCell.UIKit inside SwiftUI. UIViewRepresentable and UIViewControllerRepresentable create, update and tear down the wrapped object. Apple: the system "doesn't automatically communicate changes occurring within your view to other parts of your SwiftUI interface" — you provide a Coordinator to forward target-action and delegate messages.
The life cycle, last. Migrating to the SwiftUI life cycle covers the new
Appentry point, keeping delegate callbacks with UIApplicationDelegateAdaptor, and removing storyboards and their Info.plist keys once they are no longer needed. Apple warns that declaring the adaptor more than once raises a runtime error.
Rules worth adding to AGENTS.md or CLAUDE.md:
Migration: one screen per change. New screens are SwiftUI hosted in UIHostingController until the app entry point moves. Wrap UIKit views SwiftUI still needs in a representable with a Coordinator; no global singletons to pass events. Do not switch to the SwiftUI App life cycle until the root navigation is SwiftUI. Declare UIApplicationDelegateAdaptor once. Confirm APIs on developer.apple.com.
Step 1: install one interop skill and one UIKit skill
Ask the agent to:
install SwiftUI UIKit Interop (
npx skills add SwiftyJourney/swiftui-uikit-interop-skill). It covers hosting controllers and their sizing, hosting-configuration cells, representables with coordinators, data passing across the boundary and incremental life-cycle migration.Install UIKit Agent Skill (
npx skills add https://github.com/tornikegomareli/UIKit-Agent-Skill --skill uikit-max) so the UIKit half is reviewed against current APIs, with older-version fallbacks named for your deployment target.If the old code is Objective-C, add Objective-C iOS Maintenance for bridging headers, generated
-Swift.h, nullability andNS_SWIFT_NAMEbefore any screen moves.
Honest limit: an interop skill plus a UIKit skill is enough. A general SwiftUI pack (Apple Skills or SwiftUI Expert) helps once screens are on the SwiftUI side.
Step 2: pick the first screen
Have the agent inventory screens before it writes code, and start with a leaf: a settings or detail screen with no children, few delegates and its own data. Avoid the root navigation controller and anything with custom container transitions first. Each move gets its own PR: new SwiftUI view, a UIHostingController at the old call site, and the old view controller deleted only when the new screen's tests pass.
Step 3: keep the bridges thin
Hosting. Pass data through the SwiftUI view's initializer or an observable model; do not reach into the view from the hosting controller after creation. Check sizing and Auto Layout when embedding as a child.
Representables. Use
makeUIView/updateUIViewfor state flowing in and the Coordinator for events flowing out — the split Apple documents. A map view, camera preview or a complex text view often stays wrapped for a long time; that is fine.Cells. Prefer
UIHostingConfigurationover hand-rolled hosting controllers inside cells.
Step 4: move the entry point last, then verify
When the root is SwiftUI, follow Apple's life-cycle article: add the App structure, keep delegate methods via UIApplicationDelegateAdaptor (once), remove storyboards and the related Info.plist keys, and stop setting a root view controller at launch. Treat a second delegate adaptor, a storyboard left in the launch path, or a migrated screen without a UI test as merge blockers.
Tools compared (5)
| Tool | Best for | Agents (README) | Install (README) | License | Stars | Last push |
|---|---|---|---|---|---|---|
| SwiftUI UIKit Interop (SwiftyJourney) | The migration boundary: UIHostingController, UIHostingConfiguration, representables with coordinators, data passing, AppDelegate/SceneDelegate → SwiftUI App life cycle | Claude Code, Cursor, GitHub Copilot, Windsurf | npx skills add SwiftyJourney/swiftui-uikit-interop-skill | MIT | 1 | 10 Aug 2026 ⚠ |
| UIKit Agent Skill (tornikegomareli) | The UIKit side: current APIs with older fallbacks (iOS 13–26 range per README), view-controller lifecycle, diffable data sources, UIHostingConfiguration cells, deprecated-API review | Claude Code, Cursor, Codex, Gemini | npx skills add https://github.com/tornikegomareli/UIKit-Agent-Skill --skill uikit-max | MIT | 49 | 5 Jul 2026 ⚠ |
| Objective-C iOS Maintenance (sun6762) | Legacy Objective-C/UIKit apps: Swift interop (bridging header, -Swift.h, nullability, NS_SWIFT_NAME), ARC and retain cycles before migration | Claude Code, Codex | git clone https://github.com/sun6762/objc-ios-maintenance.git ~/.claude/skills/objc-ios-maintenance | MIT | 182 | 26 Jul 2026 ⚠ |
| Apple Skills (Prisma-Labs-Dev) | Broad pack with separate uikit and SwiftUI skills when the codebase is mixed for a long time | Claude Code, Codex, Cursor | claude plugin marketplace add Prisma-Labs-Dev/apple-skills then claude plugin install apple-skills@apple-skills | MIT | 353 | 26 Sep 2026 ⚠ |
| SwiftUI Expert (SwiftyJourney) | The SwiftUI side after a screen moves: state, composition, modern-API replacements, app structure and scenes | Claude Code, Cursor, GitHub Copilot, Windsurf | npx skills add SwiftyJourney/swiftui-expert-skill | MIT | 3 | 10 Aug 2026 ⚠ |
⚠ = no push for more than 4 weeks. All five tools are older than four weeks on 4 Nov 2026; Apple's interop APIs above are stable, but verify any iOS 26/27-specific recommendation against current documentation.
Which one to pick:
Default for the boundary and life cycle: SwiftUI UIKit Interop.
UIKit code that must stay correct while it waits: UIKit Agent Skill.
Objective-C codebase: Objective-C iOS Maintenance first.
Already using a broad Apple pack: Apple Skills; add SwiftUI Expert for the new screens.
A prompt that keeps the agent honest
Setting up the agent itself: Claude Code for iOS development, Codex for iOS development or Cursor rules for SwiftUI. Skills for new SwiftUI code: Best Claude Code skills for SwiftUI.
Migrate SettingsViewController to SwiftUI. One screen only. Build the SwiftUI view, present it with UIHostingController at the existing call site, and keep any UIKit subview SwiftUI still needs in a UIViewRepresentable with a Coordinator for its delegate. Do not touch the app entry point or storyboards. Add a UI test for the new screen, then delete the old view controller. Confirm each API on developer.apple.com.
FAQ
- Can an AI agent migrate a whole UIKit app to SwiftUI in one pass?
- It can try, but Apple's documented path is incremental. UIKit integration in the SwiftUI docs describes hosting controllers that add SwiftUI views to UIKit interfaces and representables that bring UIKit views into SwiftUI, so screens can move one at a time while the app keeps shipping. Ask the agent for one screen per change, with the old screen still reachable until the new one passes its tests.
- How does an agent put a SwiftUI view inside a UIKit app?
- With UIHostingController, which Apple describes as a UIKit view controller that manages a SwiftUI view hierarchy. You create it with the SwiftUI root view and then present it or embed it as a child view controller like any other view controller. For table and collection view cells, UIHostingConfiguration hosts SwiftUI views inside a UITableViewCell or UICollectionViewCell.
- How does SwiftUI reuse a UIKit view the agent can't rewrite yet?
- Through UIViewRepresentable or UIViewControllerRepresentable. Apple notes the system doesn't automatically communicate changes inside the wrapped view to the rest of your SwiftUI interface, so you provide a Coordinator to forward target-action and delegate messages. Tell the agent to keep the wrapper thin and route events through the coordinator rather than global state.
- When should the app switch to the SwiftUI App life cycle?
- Last, after most screens are SwiftUI. Apple's Migrating to the SwiftUI life cycle article covers changing the entry point to an App structure, using UIApplicationDelegateAdaptor to keep app delegate methods, and removing storyboards and the related Info.plist keys when they are no longer needed. SwiftUI raises a runtime error if the delegate adaptor is declared more than once.
- Which skill should I give the agent for a UIKit to SwiftUI migration?
- After the next catalog merge, SwiftUI UIKit Interop by SwiftyJourney covers hosting controllers, hosting configuration cells, representables with coordinators and life-cycle migration in one skill. Pair it with UIKit Agent Skill for the UIKit side and its deprecated-API checks, or Objective-C iOS Maintenance when the old code is Objective-C with a bridging header.