Uncovering the Undocumented avoidsOrphans
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
SwiftUI's Text view silently applies an orphan-avoidance strategy (pushOut) that can leave awkward gaps in narrow or mixed-language layouts, with no public API to disable it. The post uncovers the undocumented `avoidsOrphans(_:)` modifier that has existed in SwiftUI's binary since iOS 16 but was never exposed publicly. It explains why the NSAttributedString workaround fails (Text overwrites paragraph styles from EnvironmentValues), then shows how to reach the hidden symbol by creating a custom `.swiftinterface` file that uses `-module-abi-name SwiftUI` to redirect linker resolution to the real system implementation. Step-by-step Xcode configuration is provided. The post is candid about App Store risk under guideline 2.5.1 and frames the technique as a research/internal-tooling approach rather than a shipping recommendation.