Symlink SafeDICore into SafeDIMacros to eliminate x86_64 host builds#222
Merged
Symlink SafeDICore into SafeDIMacros to eliminate x86_64 host builds#222
Conversation
… builds Xcode builds SPM macro targets for only the active architecture (arm64 on Apple Silicon), but builds their library dependencies as universal binaries (arm64 + x86_64). This caused SafeDICore to be compiled for x86_64 as a transitive macro dependency, adding unnecessary build time for all consumers. By symlinking the SafeDICore source directory into SafeDIMacros, the core sources are compiled directly as part of the macro target rather than as a separate library. Since Xcode correctly single-archs macro executables, this eliminates all x86_64 compilation for macro-only consumers (e.g. those using SafeDIPrebuiltGenerator). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #222 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 40 40
Lines 6128 6128
=========================================
Hits 6128 6128
🚀 New features to boost your workflow:
|
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.
Summary
Xcode has a bug where it builds SPM macro library dependencies as universal (arm64 + x86_64) macOS binaries, even though it correctly builds the macro executable itself for only the active architecture. This caused
SafeDICore— a dependency ofSafeDIMacros— to be unnecessarily compiled for x86_64 on Apple Silicon Macs, adding extra build time for every SafeDI consumer.This PR symlinks the
SafeDICoresource directory intoSafeDIMacrosso that the core sources are compiled directly as part of the macro target rather than as a separate library target. Since Xcode single-archs macro executables, this eliminates all x86_64 compilation for macro-only consumers (e.g. those usingSafeDIPrebuiltGeneratoror just theSafeDIlibrary without the build tool plugin).What changed
Sources/SafeDIMacros/SafeDICore -> ../SafeDICoreso SafeDICore sources compile as part of the SafeDIMacros moduleSafeDICorefromSafeDIMacrosandSafeDIMacrosTeststarget dependenciesimport SafeDICorefrom macro source and test filessafeDICoreDependenciesarray to keepSafeDICore(still used bySafeDITool) andSafeDIMacrosin syncWhy this matters
Before this change, building a project that depends on SafeDI for iOS Simulator on Apple Silicon produced ~114 x86_64 compilation steps for
SafeDICorealone. After this change: zero x86_64 compilations for macro-only consumers.This follows the same symlink pattern already used by the SafeDI plugins (e.g.
SafeDIGeneratorsymlinksSafeDIRootScannerCoresources).Test plan
swift buildsucceedsswift testpasses all 768 tests🤖 Generated with Claude Code