Skip to content

[Feature]: Add "verify" option to xcprojformatter #20

Open

Description

@samuelmurray

Describe the feature

Add a new option to xcprojformatter that "verifies" an .xcproj file. If the file is already in the canonical format (i.e. the file is unaffected by running xcprojformatter --update project.xcproj), the command succeeds; if the file is not in the canonical format (the file is modified by running xcprojformatter --update project.xcproj) the command fails.
This could either be a new flag, such as xcprojformatter --verify --input project.xcproj, or a new subcommand, xcprojformatter verify --input project.xcproj.
In its simplest form, a failing verification simply fails with no output. A more user-friendly version would give some sort of output to indicate what part of the file that is not in the canonical format.

Use case

Having a verify option is great in CI pipelines for Xcode projects. With it, one could enforce in PRs that the .xcproj file is not modified such that it's no longer in the canonical format. This is similar to how swift format lint can be used for source code, including Package.swift.

Alternatives considered

It is possible to do this manually, by running xcprojformatter --input <...> --output <...> and comparing the files. However, it would be natural if the cli provided this out-of-the-box.

Additional context

No response

Activity

  1. added
    enhancement
    on Oct 29, 2026
  2. deccylol commented on Nov 15, 2026

    @deccylol
    Collaborator

    Hi! 👋 This sounds cool.

    A more user-friendly version would give some sort of output to indicate what part of the file that is not in the canonical format.

    How verbose do you expect this to be? Such a tool wouldn't provide semantic correctness without a higher-level API (#22). For output reporting, I expect a lot of diff-issues like whitespace and trailing commas. For missing properties (e.g. a target's name), simply decoding will provide enough information to tell you what went wrong:

    $ xcrun xcprojformatter --input proj.xcodeproj
    Missing required value for key “name” at “/targets[0]”
    

    Is the 0/1 exit code sufficient to report correctness, given that it's syntactic, not semantic? I think so.

  3. samuelmurray commented on Nov 16, 2026

    @samuelmurray
    Author

    @deccylol yeah, I think only exit code would be a good start.
    My comment about more detailed output was inspired by how a linter, eg swift-format, can point to what needs fixing. But seeing that most (all?) issues from this tool would be fixed by a user running the tool (rather than manually editing the file), I think it's not a necessary part. And since it would require more capabilities than the tool already has, I think it could be seen as a future improvement.

  4. zachshallbetter commented on Nov 24, 2026

    @zachshallbetter

    I tried the format-and-compare workaround on a small project. The formatter exited 0 for both the canonical file and the same file with an extra newline. Comparing the bytes caught the difference and left the project file untouched.

    The 0/1 exit status discussed above would cover that CI use case for me. If nobody’s working on this and the scope still sounds right, I’d be happy to take a pass at --verify and add tests for both cases.

    Update: I opened #30 with the exit-code-only --verify mode. It leaves the input untouched and tests both a canonical file and the extra-newline case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions