You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Add "verify" option to xcprojformatter #20
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.
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.
@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.
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.
Activity
deccylol commentedon Nov 15, 2026
Hi! 👋 This sounds cool.
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:
Is the 0/1 exit code sufficient to report correctness, given that it's syntactic, not semantic? I think so.
samuelmurray commentedon Nov 16, 2026
@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.
zachshallbetter commentedon Nov 24, 2026
I tried the format-and-compare workaround on a small project. The formatter exited
0for 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/1exit 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--verifyand add tests for both cases.Update: I opened #30 with the exit-code-only
--verifymode. It leaves the input untouched and tests both a canonical file and the extra-newline case.