Challenges of mixed SwiftUI and UIKit codebases in iOS Apps
Mixing SwiftUI into Medium's 2013-era UIKit iOS app brings recurring friction: sizing SwiftUI views hosted in UIHostingController as table/collection cells, mismatched scroll APIs (offset sign differs), and duplicated components like PostPreview implemented in both frameworks. Medium keeps UIKit for app-wide navigation and SwiftUI for local feature navigation, avoids SwiftUI TextField due to focus limitations, and notes weaker SwiftUI view debugging. A scroll performance issue from wrapping UILabel with NSAttributedString in a SwiftUI list was fixed by switching to native Text with AttributedString; raising the minimum target from iOS 13 to 16 reduced version-specific code.
Related posts
- How we build SwiftUI features in the Medium application
Medium Engineering mediumAdeptMedium's iOS team builds new iOS 13+ features in SwiftUI and Combine by splitting a monolithic, partly Objective-C codebase into Swift packages: ApolloModel for generated GraphQL models, SharedUI components, per-feature UI packages, and planned LiveService/FakeService packages. Network services are structs returning Combine publishers, with live and fake implementations injected through initializers in a style inspired by Point-Free, rather than being registered in a global service registry. Views take protocol-backed GraphQL fragments so previews and tests can use simple structs, and enum action handlers forward events to custom UIHostingControllers for app-level navigation. Building packages in isolation makes SwiftUI previews fast, though List, NavigationView and Menu still have gaps that require OS-version workarounds.
- Lessons From Building iOS Widgets
Shopify Engineering mediumAdeptShopify rebuilt its iOS analytics widgets natively in SwiftUI rather than React Native, because app extensions have tight memory limits, WidgetKit serializes SwiftUI view hierarchies, and React Native had no official widget support. Each widget fetches data independently through Reportify/ShopifyQL while sharing session tokens with the app. iOS calls getTimeline and getSnapshot several times per update cycle, which caused redundant network calls and a token-refresh race that logged users out. A one-minute per-widget cache keyed on configuration fixed both problems. The post also covers a flexible metric decoder, a size-agnostic SwiftUI layout built on LazyVGrid and an OptionSet of layout options, and why relative timestamps were rejected for lack of customization.
- How we brought Datadog’s data visualization to iOS: A focus on performance
Datadog Engineering mediumAdeptDatadog built DogGraphs, an internal SwiftUI graphing library constrained to iOS 14 (no Canvas), with a result-builder API that type-checks graph compositions at compile time. Profiling with _printChanges() and Xcode Instruments showed that layers observing a shared EnvironmentObject coordinate system caused twice the expected body evaluations (339 vs 113 for a 113-line chart). Moving coordinate-system reduction into the @resultBuilder via TupleGraphContent fixed that. For charts with thousands of bars, a Batch content type groups shapes by fill and stroke style and draws each group as a single Path, which removes the rendering hangs. The post also explains SwiftUI's diffing order: memcmp for POD views, then Equatable, then reflection.
- How We Built The Deals Tab in Swift UI
Etsy Code as Craft mediumAdeptEtsy rebuilt its mobile Updates tab as a new Deals tab in SwiftUI inside a modular Tuist module, which made preview builds nearly instant and let the team build modules from mock preview data about two weeks before the APIs were ready. The screen is a SwiftUI List of typed API modules decoded with a Decodable-based APIv3 layer, and nested `Previews` enums supply mock models at every level. To meet the Cyber Week deadline without rewriting legacy Objective-C code, navigation, favoriting and logging are handed back to the main target through custom `@Environment` action handlers. Legacy listing cards are injected as UIViewRepresentable view builders from the UIKit hosting controller.
- What the iPhone Duo means for web development
Mux mediumAdept
Safari on the foldable iPhone Duo exposes the Device Posture API and Viewport Segments API behind WebKit feature flags. They let pages detect a folded posture via `navigator.devicePosture` or `@media (device-posture: folded)` and position content per screen segment with `env(viewport-segment-*)` variables. Using these plus a flagged Fullscreen API, a Netflix-style folded video player was built from Video.js v10 components, with video on the top half and tiled controls on the bottom. A blurred, mirrored reflection is drawn by copying frames to a small canvas via requestVideoFrameCallback, since -webkit-box-reflect doesn't work on video in iOS Safari. In practice it needs three feature flags on iOS, and Chromium on a Pixel Fold clips fullscreen content to the top half, so the design isn't shippable today.