Skip to content

feat(validate): add validate command with structured JSON output#1611

Open
samuraisatoshi wants to merge 2 commits intoyonaskolb:masterfrom
samuraisatoshi:feat/validate-command
Open

feat(validate): add validate command with structured JSON output#1611
samuraisatoshi wants to merge 2 commits intoyonaskolb:masterfrom
samuraisatoshi:feat/validate-command

Conversation

@samuraisatoshi
Copy link
Copy Markdown

Summary

Adds a new xcodegen validate command that validates the project spec without generating a project, producing structured JSON output.

  • Validates one or more specs (comma-separated --spec paths)
  • Catches parsing errors, validateProjectDictionaryWarnings, validateMinimumXcodeGenVersion, and project.validate() — each attributed to a stage
  • Outputs a JSON object with valid, errors, and warnings arrays
  • Exits with code 1 when the spec has errors (so CI can gate on it)

JSON output

{
  "errors": [],
  "valid": true,
  "warnings": []
}

Error/warning objects:

{
  "errors": [
    { "stage": "parsing", "message": "..." },
    { "stage": "validation", "message": "Target 'Missing' not found" }
  ],
  "valid": false,
  "warnings": []
}

Use cases

  • CI pre-check: validate spec before running generate, with machine-readable output
  • Editor integration: parse JSON to show inline errors
  • Multi-spec monorepos: --spec app/project.yml,lib/project.yml validates both, aggregates results

Test plan

  • xcodegen validate on valid spec → "valid": true, exit 0
  • xcodegen validate on invalid spec → "valid": false, errors populated, exit 1
  • xcodegen validate --spec missing.yml → parsing error captured in JSON, exit 1
  • xcodegen validate --spec a.yml,b.yml → errors from both specs aggregated
  • swift test passes

🤖 Generated with Claude Code

samuraisatoshi and others added 2 commits March 28, 2026 21:59
Adds a new --dry-run flag to the generate command that generates the
Xcode project in memory and prints a JSON diff of what would change
compared to the existing project on disk, without writing any files.

New type ProjectDiff captures added/removed/modified file keys in the
pbxproj and serialises them as JSON.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a new `xcodegen validate` command that validates the project spec
without generating a project.

Output is always a JSON object with three keys:
  - valid (bool): whether the spec passed all checks
  - errors (array): each with stage and message fields
  - warnings (array): same shape

This separates validation from generation and enables CI pipelines to
get machine-readable validation results. Supports comma-separated --spec
paths and all existing ProjectCommand flags (--no-env, --project-root).

Exit code is 1 when the spec has errors, 0 when valid.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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