Repository navigation
packer: fix dead-stripped app extensions and missing cross-import overlays - #460
mw2mw3dirtshowdown-del wants to merge 3 commits into
Conversation
App extensions link with -e _NSExtensionMain, so nothing references the product's generated `main` at link time. Under -dead_strip (the SwiftBuild default) that strips the whole extension, producing an appex with no __text — which then fails code signing. Emit a weak-import anchor for `main` in the generated stub.c: it keeps the entry point (and everything reachable from it) alive when present and compiles to NULL for extensions without one. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The SwiftBuild backend's dependency scan runs without -enable-cross-import-overlays, so SDK cross-import modules like _PhotosUI_SwiftUI never reach the explicit module map and types such as PhotosPickerItem fail to resolve. Pass the flag through -Xswiftc so overlay modules are wired into the map. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Pull the stub.c contents out of build() into a static stubSource(for:) so the dead-strip anchor is covered by a unit test instead of only by end-to-end device deploys. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
Two fixes to
Packer.swiftfor projects built through the SwiftBuild backend (i.e. on Linux), verified end-to-end on a real iOS app with a WidgetKit extension deployed to a physical device.mainagainst dead stripping. Extensions are linked with-e _NSExtensionMainplus-dead_strip. Nothing in_NSExtensionMainstatically references the extension's Swift@main, so the linker strips the entire product graph — the resulting.appexbinary has no__textsection at all (49 KB stub vs ~500 KB real code) and can't even be code-signed. Fix: the generatedstub.cfor extension products now carries aweak_importanchor tomain, which roots the object graph whenmainexists and links cleanly (NULL) for extensions without one (e.g. ObjC principal-class extensions).-enable-cross-import-overlays, so SDK cross-import modules like_PhotosUI_SwiftUInever reach the target's explicit module map —PhotosPickerItemand friends fail to resolve even thoughPhotosUIis imported. Pass the flag through-Xswiftc -Xfrontendso overlay modules are wired into the map (raw-enable-cross-import-overlaysis rejected by the driver, hence the frontend passthrough).Test plan
.appexbinary contains__text+__swift5_entry(49 load commands) after fix_PhotosUI_SwiftUIand_AppIntents_SwiftUIpresent in generated explicit module mapmake lintclean (0 violations)swift build --target PackLibclean onmain+ these commitsGenerated with Devin
Summary by CodeRabbit