Skip to content

Symlink SafeDICore into SafeDIMacros to eliminate x86_64 host builds#222

Merged
dfed merged 1 commit intomainfrom
dfed--symlink-safedicore-into-macros
Apr 6, 2026
Merged

Symlink SafeDICore into SafeDIMacros to eliminate x86_64 host builds#222
dfed merged 1 commit intomainfrom
dfed--symlink-safedicore-into-macros

Conversation

@dfed
Copy link
Copy Markdown
Owner

@dfed dfed commented Apr 6, 2026

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 of SafeDIMacros — to be unnecessarily compiled for x86_64 on Apple Silicon Macs, adding extra build time for every SafeDI consumer.

This PR symlinks the SafeDICore source directory into SafeDIMacros so 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 using SafeDIPrebuiltGenerator or just the SafeDI library without the build tool plugin).

What changed

  • Added a symlink Sources/SafeDIMacros/SafeDICore -> ../SafeDICore so SafeDICore sources compile as part of the SafeDIMacros module
  • Removed SafeDICore from SafeDIMacros and SafeDIMacrosTests target dependencies
  • Removed import SafeDICore from macro source and test files
  • Extracted shared SwiftSyntax dependencies into a safeDICoreDependencies array to keep SafeDICore (still used by SafeDITool) and SafeDIMacros in sync

Why 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 SafeDICore alone. 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. SafeDIGenerator symlinks SafeDIRootScannerCore sources).

Test plan

  • swift build succeeds
  • swift test passes all 768 tests
  • Verified a macro-only consumer package has zero x86_64 compilation lines when building for iOS Simulator on Apple Silicon

🤖 Generated with Claude Code

… 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
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e33f0f5) to head (3b52298).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #222   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           40        40           
  Lines         6128      6128           
=========================================
  Hits          6128      6128           
Files with missing lines Coverage Δ
Sources/SafeDIMacros/Macros/InjectableMacro.swift 100.00% <ø> (ø)
...ources/SafeDIMacros/Macros/InstantiableMacro.swift 100.00% <ø> (ø)
...SafeDIMacros/Macros/SafeDIConfigurationMacro.swift 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dfed dfed marked this pull request as ready for review April 6, 2026 22:00
@dfed dfed merged commit 4a4249e into main Apr 6, 2026
19 checks passed
@dfed dfed deleted the dfed--symlink-safedicore-into-macros branch April 6, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant