Skip to content

Remove unnecessary Defaults dependency from macro target#223

Merged
sindresorhus merged 1 commit intosindresorhus:mainfrom
drekka:fix/mac-catalyst-archive
Mar 23, 2026
Merged

Remove unnecessary Defaults dependency from macro target#223
sindresorhus merged 1 commit intosindresorhus:mainfrom
drekka:fix/mac-catalyst-archive

Conversation

@drekka
Copy link
Copy Markdown
Contributor

@drekka drekka commented Mar 23, 2026

Note this fix and PR where supplied by Claude after we were diagnosing a failure to archive an app I'm building. Claude told me the problem was effectively a circular dependency of Defaults -> Defaults Macros -> Defaults which was as per its description below, causing duplicate compilations. This only occurred during archiving and not during normal development.

Summary

The DefaultsMacrosDeclarations macro target declares "Defaults" as a dependency in Package.swift, but the macro source files only import SwiftSyntax modules — they generate source code strings containing Defaults references but never import or link against the Defaults library itself.

This unnecessary dependency causes Mac Catalyst archive builds to fail with "Multiple commands produce" errors for Defaults.o and Defaults_Defaults.bundle. The root cause:

  • .macro targets are compiled for the host platform (macOS)
  • When the app target is Mac Catalyst (also a macOS variant), the Defaults library gets built for both host and target
  • Both builds produce output files at the same path, causing Xcode's archive build system to reject the duplicate outputs

Fix

Remove "Defaults" from the DefaultsMacrosDeclarations target's dependencies. The macro implementation only needs SwiftSyntax.

Verification

  • All 289 package tests pass
  • Mac Catalyst archive build succeeds
  • Regular iOS and macOS builds unaffected

The `DefaultsMacrosDeclarations` macro target only uses SwiftSyntax
modules — it generates source code strings containing Defaults
references but never imports or links against the Defaults library
itself.

Having `Defaults` as a dependency of the `.macro` target causes Mac
Catalyst archive builds to fail with "Multiple commands produce"
errors. Macro targets are built for the host platform (macOS), and
when the app target is Mac Catalyst (also a macOS variant), the
Defaults library gets built for both host and target, producing
duplicate output files at the same path.

Removing this dependency fixes the archive collision while all 289
package tests continue to pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sindresorhus sindresorhus merged commit d9406c9 into sindresorhus:main Mar 23, 2026
2 checks passed
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.

2 participants