Repository navigation
fix(compose): prefer the SwiftUI host over a generated runner (#180) - #181
Merged
Merged
Conversation
When a Compose project has both a SwiftUI @main host in iosApp/ and a Kotlin ComposeUIViewController entry, build the Swift host instead of a generated Objective-C runner, so its launch setup and Swift dependencies are kept. Add --entry auto|swift|kotlin to compose build and run to pick the entry point explicitly.
…180) A KMP framework whose dependencies contain Swift code autolinks -lswiftCore and the -lswiftCompatibility* archives. ld64.lld got no search path for them, so the generated runner failed to link. Pass the SDK's usr/lib/swift (runtime stubs) and the toolchain's usr/lib/swift/<platform> (compatibility archives), as swiftc does for the Swift runner. Verified with a real ld64.lld link: both are required, and links without Swift objects are unchanged.
Add a 'Choosing the app entry point' section with the auto/swift/kotlin table, examples and the build/run option lists. --framework now ignores --entry, as documented, so a missing entry cannot fail a framework-only build.
This comment has been minimized.
This comment has been minimized.
Contributor
Integration simulator reportxcross: Failed jobs✅ No failed jobs. Flutter
Compose
Screenshots are Actions artifacts of this run. They open in the browser and expire after 30 days. |
Owner
Author
|
@skaldebane, could you please try this branch and tell me if fix your problem
|
|
yep, this seems to work perfectly well now. thanks for the quick fix! |
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.
Fixes #180.
Problem
When a Compose project had both a SwiftUI
@mainApp iniosApp/and a KotlinComposeUIViewControllerentry,xcross compose build/runpicked the Kotlin entry and generated an Objective-C runner. That skipped the existing Swift app and its launch setup, and failed to link when a dependency needed the Swift runtime libraries.Changes
KmpEntryDiscovery.classifyEntrynow prefers the SwiftUI host, then the Kotlin entry, then framework-only.--entry auto|swift|kotlinoption onxcross compose buildandxcross compose run(defaultauto).--entry kotlinrestores the generated runner.--entry swiftrequires the SwiftUI host. Both fail with a clear error when the requested entry is missing.xcross compose doctornow checks Swift imports for such projects too, since the Swift host is what gets built.Tests
kmp_project_test.dart: precedence with both entries,--entry kotlin/swiftselection and errors, a non-AppSwift file next to a Kotlin entry stays a Kotlin app.compose_pack_operation_test.dart:options.entryreaches detection.compose_command_args_test.dart:--entryparsing for build and run.doctor_command_test.dart: updated for the new precedence.dart analyzeclean,dart testinpackages/xcross: all 2340 tests pass.Swift runtime in the generated runner
The generated Objective-C runner (still used with
--entry kotlinor without a SwiftUI host) linked withld64.lldand no Swift search path, so a KMP framework whose dependencies contain Swift code failed with undefined Swift runtime symbols. The link now passes-L <SDK>/usr/lib/swift(runtime stubs) and-L <toolchain>/usr/lib/swift/<platform>(libswiftCompatibility*.a), asswiftcdoes for the Swift runner.Verified with a real
ld64.lldlink of an ObjCmain.oagainst a Swift object (iOS 15.0 and 13.0 targets): without the flags it fails with undefined Swift symbols. With only one of the two paths it still fails. With both it links, andotool -Lshows only/usr/lib/swift/*.dylib(no@rpath/libswift*, so nothing extra to embed). A link with no Swift objects is unchanged.runner_builder_test.dartasserts the new arguments.