Validate Package.swift is Parseable


If anyone is aware of a tool or an approach or a discussion about Package.swift file validation in terms of being parseable, please let me know about it.

The only solution I could find so far is to run

swift package dump-package

If the package is not parseable, an error will be shown.

Is there a better way or a designated tool?


I use swift package describe when I want to validate a manifest. It is no more specific to the task than dump-package, but it outputs far less of the unnecessary information. (And on my keyboard, describe is 8 key presses vs the 15 for dump-package, but your keyboard is probably different.)

If you find yourself doing it a lot you can register a shell alias like this:

alias validate="if swift package describe > /dev/null ; then echo \"✓ Manifest is valid.\" ; fi"

Then all you have to type is validate, and it will either print (only) the errors, or print “✓ Manifest is valid.”