4.8 · Mixed-language projects, costs, and migrating a large app
Real teams do not rewrite. They live in mixed targets for years, so the skills that matter are wiring the languages together, knowing what the seam costs, and steering a migration that never breaks the app.
Mental model. Treat the boundary as a product. Keep it small, typed and well tested, and move the code on either side of it one safe piece at a time.
Wiring the languages together
Headers, modules, and what each language can see.
- How do Swift and Objective-C see each other: bridging header, umbrella header, and the -Swift.h file?
Two headers, one in each direction. For Swift to see Objective-C, an app target uses a bridging header (MyApp-Bridging-Header.h) that imports every ObjC header…
Cost and strategy
What crossing the border costs, and how to migrate without a rewrite.
- What does mixing Swift and Objective-C cost, and how do you keep the cost down?
Costs arrive in four places. Runtime: a call that crosses into Objective-C goes through objc_msgSend and retain and autorelease traffic, and bridging String… - How would you plan the migration of a large Objective-C app to Swift?
Do not rewrite. Migrate incrementally, behind stable seams, and keep the app shippable every week. First, make the Objective-C pleasant for Swift without…
More in Objective-C & interop
- 4.1 · Message send, selectors, forwarding, isa
- 4.2 · Categories, associated objects, load and initialize
- 4.3 · NSObject, class clusters, copying
- 4.4 · @objc, what does not bridge, and error bridging
- 4.5 · Nullability, lightweight generics, Swift-friendly names
- 4.6 · Method swizzling, and when it is a footgun
- 4.7 · Reading Objective-C, blocks, and manual reference counting
- 4.9 · How Objective-C declarations arrive in Swift
- 4.10 · The runtime up close: introspection, encodings, IMPs and exceptions
- 4.11 · Key-value coding and observing
- 4.12 · What crosses the boundary: inference and concurrency