AGENT SKILL

xcodebuild-plugin-macro-validation-per-invocation

An SPM dependency with a build-tool plugin and/or macro (e.g. an MLX package) makes a specific xcodebuild invocation fail with "Plugin ... must be enabled" / "must be enabled to be used" and run 0 build/test steps, even though another invocation of the same project (build.sh, an IDE scheme) already works fine — because -skipPackagePluginValidation -skipMacroValidation must be passed per xcodebuild invocation and do not propagate across gym/fastlane/CI/IDE call sites. Use when adding a package with a build-tool plugin or Swift macro to a project with more than one place that shells out to xcodebuild, when a release/CI lane fails at the plugin-trust prompt while other build paths work, or when reviewing an automated repair/fix-stage commit that resolves a build failure by writing machine-wide Xcode defaults.

License 许可
MIT
最近更新
2026-11-07
Stars
★ 1
Forks
1

01 前言 Front Matter

name
xcodebuild-plugin-macro-validation-per-invocation
description
An SPM dependency with a build-tool plugin and/or macro (e.g. an MLX package) makes a specific xcodebuild invocation fail with "Plugin ... must be enabled" / "must be enabled to be used" and run 0 build/test steps, even though another invocation of the same project (build.sh, an IDE scheme) already works fine — because -skipPackagePluginValidation -skipMacroValidation must be passed per xcodebuild invocation and do not propagate across gym/fastlane/CI/IDE call sites. Use when adding a package with a build-tool plugin or Swift macro to a project with more than one place that shells out to xcodebuild, when a release/CI lane fails at the plugin-trust prompt while other build paths work, or when reviewing an automated repair/fix-stage commit that resolves a build failure by writing machine-wide Xcode defaults.

03 SKILL.md 正文

xcodebuild Plugin/Macro Validation: Per-Invocation Flags, Never a Machine-Wide Default on a Persistent Mac

Symptom

A fastlane archive (or any second/independent xcodebuild invocation — a second script, a second IDE scheme) dies at a plugin-trust prompt:

Validate plug-in 'CudaBuild' in package 'mlx-swift'

or the more generic Plugin ... must be enabled / must be enabled to be used, running 0 build/test steps — even though another build path for the same project already works fine (a local build.sh, a different scheme).

Root cause

-skipPackagePluginValidation -skipMacroValidation are xcodebuild flags, and xcodebuild flags do not propagate between independent invocations. A project's primary build wrapper (build.sh) may already pass these flags for local/CI builds, but a separate fastlane archive lane (gym) invokes xcodebuild independently with its own xcargs (provisioning, auth key) — and if that lane predates the package with the build-tool plugin, it was never updated to add them. Every place that shells out to xcodebuild independently is its own invocation with its own flag set; fixing one doesn't fix the others.

Fix

Add the flags per-invocation, everywhere xcodebuild gets shelled out to independently — grep the whole repo for every xcodebuild/gym invocation site whenever adding a package with a build-tool plugin or macro, and add both flags to each one found:

# Fastfile — gym xcargs, alongside existing provisioning/auth flags
gym(
  scheme: "App",
  xcargs: "-allowProvisioningUpdates -skipPackagePluginValidation -skipMacroValidation",
  # ...
)
# build.sh (or any script that shells out to xcodebuild) — same flags, same reasoning
xcodebuild -scheme App -skipPackagePluginValidation -skipMacroValidation build

Do NOT reach for the machine-wide fix on a developer or other persistent Mac — defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation / IDESkipMacroFingerprintValidation — even though it "fixes" every invocation at once. It silently disables plugin/macro fingerprint validation (a real supply-chain control) for every project on the machine, forever, not just this one. Per-invocation flags are scoped to the build that actually needs the exception; a machine-wide default is a standing security regression that outlives the project that prompted it.

Xcode Cloud carve-out. Hosted Xcode Cloud runs xcodebuild itself and accepts no flags, and ci_post_clone.sh has no xcodebuild call to add them to. There the ephemeral, single-use VM may use the defaults write above from inside ci_post_clone.sh (it is discarded after the run). Pasteable lines (the first key's misspelling is Apple's):

defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES
defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES

The ban stays in force for every machine that outlives the build.

Autonomous repair-stage agents: route through the same review as any commit

A repair/fix-stage agent tasked with resolving exactly this kind of build failure is a privileged actor solving "make the error go away," not necessarily "fix the root cause safely" — it will find the broadest fix that satisfies the immediate check, and a machine-wide defaults write genuinely does make the error disappear fastest. In one case, a repair agent fixed a verify-stage plugin-validation failure by committing a shell script plus a build.sh call that wrote the machine-wide Xcode defaults above — disabling plugin/macro fingerprint validation for every project on the developer's Mac. It shipped past the wave's own per-unit reviewers (who only reviewed the named implementation units, not the repair-stage commit) and was only caught by an unrelated background commit-security review.

Route repair-stage and fix-stage commits through the exact same review pass as regular implementation commits — don't exempt the "cleanup" stage just because its job is to make a failing check pass. Prefer per-invocation flags over global defaults/env changes whenever a repair agent proposes disabling a validation gate, and treat "disables a security control machine-wide on a machine that outlives the build" as a hard stop regardless of which stage of the pipeline produced the commit. The one exemption is the ephemeral Xcode Cloud VM, where ci_post_clone.sh may write the defaults (see the Xcode Cloud carve-out above); anywhere else it stays a hard stop.

Evidence

Session 0022: "First bundle exec fastlane archive died at 'Validate plug-in CudaBuild in package mlx-swift' — gym's xcargs had -allowProvisioningUpdates + auth key but not -skipPackagePluginValidation -skipMacroValidation, the same headless-MLX trap build.sh already handles. The archive lane predates the MLX exception. Fixed by appending both flags to the gym xcargs (commit 6c2adde)... the machine-wide defaults write IDESkip…Validation path is security-reverted per AGENTS.md."

Session 0020: "the workflow's repair agent fixed a verify failure by committing scripts/trust-swiftpm-plugins.sh + a build.sh call writing MACHINE-WIDE Xcode defaults... Reverted... AGENTS.md testing section amended: xcodebuild invocations pass -skipPackagePluginValidation -skipMacroValidation per-invocation; machine-wide defaults banned... lesson: repair/fix-stage commits deserve the same review pass as unit commits."

When to Use

Any Swift project that adopts an SPM package shipping a build-tool plugin or Swift macro (increasingly common: codegen, ORM macros, MLX/ML kernels) will hit this the moment it adds a second headless-build entry point (fastlane, CI, a second script) — the fix is per-invocation flags, not something that propagates from one script to another. The repair-stage review point applies more generally to any agentic build/CI pipeline with an auto-repair or self-healing stage (not iOS-specific in principle) — a repair loop optimizing for "tests pass now" will happily trade away a security control if that's the shortest path.

Related skills

  • xcode-cloud-post-clone-contract — hosted Xcode Cloud runs its own xcodebuild with no flags, so the per-invocation fix does not apply there; see its plugin/macro-trust note and this skill's Xcode Cloud carve-out.
  • release — the fastlane archive/gym lane this fix most commonly lands in.

04 同仓库更多 Skills

abhijitbansal
abhijitbansal/claude-skills

second-wind

Orchestrate long unattended Claude Code runs across multiple repos with the wind CLI. Use when the user wants to run Claude Code overnight, resume sessions after the 5-hour usage limit, run Claude in many repos at once via tmux, or says "set up second wind", "wind up", "overnight run", "resume after limit", "usage limit orchestrator".

★ 1
abhijitbansal
abhijitbansal/claude-skills

structured-output-adaptive-thinking-token-bloat

A Claude API call using output_config.format (json_schema structured outputs) with thinking:{type:"adaptive"} burns most of its output budget on thinking (observed ~21k of ~24k tokens) without improving JSON quality, making the run up to ~5x more expensive than the same call with thinking omitted — use when calling the Messages API with a json_schema output format for extraction, ranking, classification, or summarization tasks, or when a schema-constrained call's usage.output_tokens is far larger than the returned JSON.

★ 1
abhijitbansal
abhijitbansal/claude-skills

review

Apply a code-review lens to a diff, branch, or file — find correctness bugs, security issues, and quality problems, ranked by severity, with a concrete fix for each. Use when the user says "review this", "review my diff", "check this PR", "look this over before I commit", or "is this safe". Skip when the user wants the code written, not reviewed.

★ 1
abhijitbansal
abhijitbansal/claude-skills

refresh

Rebuild the prompt-craft command registry and usage profile, and print a summary of installed commands and your personalized recommendations. Use when you install or update plugins and want the advisor to pick them up immediately, or say "refresh prompt-craft", "rebuild the command registry".

★ 1
abhijitbansal
abhijitbansal/claude-skills

refactor

Apply a refactoring lens — restructure code without changing behavior, guarded by tests that pass before and after. Use when the user says "refactor", "clean this up", "extract this", "simplify this", "reduce duplication", or "make this readable" on existing working code. Skip when the change is meant to alter behavior (that's a feature or a fix).

★ 1
abhijitbansal
abhijitbansal/claude-skills

plan

Decompose a non-trivial task into an explicit, tracked plan with goals and per-step acceptance criteria before writing code. Use when the user says "plan this", "break this down", "what's the plan", or asks for a multi-step feature/refactor that touches more than one file. Pairs with plan mode. Skip for single-edit changes that need no decomposition.

★ 1