Repository navigation
Fix launch crash on iOS 16 and 17 by weak-linking UIKit - #302
Merged
Merged
Conversation
Kotlin/Native ignores API availability and links every ObjC class strongly, unlike Swift and Clang. The UITab reference used by the native tab bar therefore made dyld abort on launch on iOS < 18 with "Symbol not found: _OBJC_CLASS_$_UITab". Linking UIKit with -weak_framework turns references to classes missing from the running iOS into nil instead. The native tab bar is only created on iOS 26+, so UITab is never used where it is missing. Any other newer UIKit class must likewise stay behind a runtime version check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Simulator debug validation does not establish weak UITab linkage in a release binary or successful launch on the oldest supported iOS, leaving critical linker and runtime behavior unverified.
No open issues 🎉
What changed in this PR
This PR addresses the template’s iOS 16 and 17 launch crash caused by a strong reference to UITab, while preserving the existing native tab bar implementation.
Changes:
- Weak-links UIKit in both ProdDebug and ProdRelease.
- Documents why the linker flag must remain and why newer iOS APIs still require runtime availability checks.
| File | Description |
|---|---|
| README.MD | Explains weak linking, availability guards, and oldest-supported-iOS testing. |
| iosApp/iosApp.xcodeproj/project.pbxproj | Adds -weak_framework UIKit to both app build configurations. |
| AGENTS.MD | Adds guidance to preserve weak linking and guard newer iOS APIs. |
Review effort: Balanced
mbernson
enabled auto-merge
November 24, 2026 13:16
kseniia-q42
approved these changes
Nov 24, 2026
kseniia-q42
left a comment
Collaborator
There was a problem hiding this comment.
Worked for my on iOS 17!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The app crashed on launch on iOS 16 and 17, before any of our code ran:
The native tab bar uses
UITab, which only exists from iOS 18 (introduced in 76582f7). Unlike Swift and Clang, Kotlin/Native ignores API availability: it compiles newer APIs without an error and links every Objective-C class strongly, so dyld aborts when the class is missing. The deployment target is 16.2.Fix
-weak_framework UIKitin the iosApp target'sOTHER_LDFLAGS(ProdDebug and ProdRelease). Classes missing on the running iOS version now resolve tonilinstead of aborting the launch. The native tab bar is only created on iOS 26+, soUITabis never used where it is missing.UITab: replacing it withsetViewControllers+UITabBarItemwould bring back the empty third tab on the iPhone Duo side rail that 76582f7 fixed.Testing
otool -lshows UIKit loaded withLC_LOAD_WEAK_DYLIB, andnm -mshows_OBJC_CLASS_$_UITabasweak external.🤖 Generated with Claude Code