Skip to content

Warn on unknown spec keys - #1673

Merged
yonaskolb merged 6 commits into
masterfrom
claude/project-thread-2sp31z
Nov 25, 2026
Merged

yonaskolb merged 6 commits into
masterfrom
claude/project-thread-2sp31z

Conversation

@yonaskolb

@yonaskolb yonaskolb commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Requested by Yonas · project thread

XcodeGen now warns about every spec key it never reads, at every level, instead of silently ignoring it:

Warning: Unknown key "resources" in targets.App will be ignored
Warning: Unknown key "buildphase" in targets.App.sources[0] will be ignored
Warning: Unknown key "targts" will be ignored

Fixes #1645 and #1526. This is an alternative to #1660, #1661 and #1528, which keep hand-written lists of valid keys. It uses key read tracking from JSONUtilities 4.3.0 (yonaskolb/JSONUtilities#1) instead, so there's no list to keep in sync. These are warnings only, and generation still continues.

Changes

  • JSONUtilities is updated to from: "4.3.0".
  • SpecLoader decodes the project inside KeyAccessTracking.record, and validateProjectDictionaryWarnings reports each unused key as SpecValidationError.ValidationError.unknownKey.
  • generate prints each validation warning on its own line with a Warning: prefix, instead of one "Spec validation error:" block.
  • Keys starting with x- are never reported, so they can hold YAML anchors.
  • Named items are decoded in their own scope, including on the parallel target path, where the tracking context is handed to each worker. Named items are targets, schemes, aggregate targets and project references.
  • Keys used before decoding are marked as read:
    • targetTemplates and schemeTemplates
    • target templates, templateAttributes, platformPrefix, platformSuffix and __declarationIndex
    • scheme templates and templateAttributes
  • Keys that are only read with raw subscripts are marked as read: testTargets, coverageTargets, scheme test targets, environment variable value and settings configs.
  • Flat settings mark all their keys as read, since they're build settings.
  • Objects decoded by hand get their own scope, with typed paths such as ["sources", .index(i)], so their keys are checked too. That covers target sources, test targets, coverage targets, test plans, environment variables, buildPhase and dependency copy.

Caught a real typo

Tests/Fixtures/TestProject/project.yml had stopOnStype: Catch on an exception breakpoint, so the breakpoint was silently generated with the default throw. It's now stopOnStyle, and the fixture's Breakpoints_v2.xcbkptlist has stopOnStyle = "1".

The testSpecWarningValidation tests also used a top-level templates: key that doesn't exist. They now use targetTemplates:.

Docs

  • ProjectSpec.md mentions the warning and the x- prefix.
  • CONTRIBUTING.md explains markRead, markAllRead and scope for anyone adding spec options.

Tests

  • testUnknownKeyWarnings checks that typos are reported with their paths. It covers the top level, options, settings, a target, a source entry, a dependency, a scheme and a scheme test target.
  • It also checks that these keys are not reported: template keys, multi-platform keys, x- keys, settings, plist properties, attributes, environment variables and command line arguments.
  • testFixturesHaveNoUnknownKeys loads 9 fixture specs and expects no unknown keys. Any spec key that's parsed in a way the tracking can't see will fail CI.

@yonaskolb
yonaskolb force-pushed the claude/project-thread-2sp31z branch from 93e1e8e to 07f1b9a Compare November 25, 2026 06:28
@yonaskolb
yonaskolb marked this pull request as ready for review November 25, 2026 06:29
…keys

- Mark a target's deploymentTarget as read when it's a per-platform map, and decode the map in its own scope so typos in it are reported
- Run the remaining loadable fixture specs through testFixturesHaveNoUnknownKeys
- Test that YAML anchors and merge keys don't produce warnings

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01237XKr4VbX6fkZgBHoh2DT
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.

Unrecognized target keys (e.g. resources:) are silently ignored — should warn

2 participants