afaicr built tools aren’t allowed to alter source files anymore for security reasons
what code generators do is emit into the generated source directory (this change broke swiftgen at some point iirc)
what you can do instead is either add a shortcut to run swiftformat on save or perhaps a githook that runs format on commit (if your using git)
edit: it seems build tools cant but custom commands may work
Custom command plugins that need to modify the package source code can specify this requirement. If the user approves, package manager grants write access to the package directory. Build tool plugins can’t modify the package source code.
A command plugin specifies the semantic intent of the command — this might be one of the predefined intents such as “documentation generation” or “source code formatting”
so looks like thats the intended method for formatting..
Right now I have added a Run script build phase and I am doing the listing there. So it runs every time I compile. I have removed Sandbox for the run script.
I am not sure if it the right way, but works.
The only problem is when I am refactoring large amounts of code, the linter updates the code and sometimes there is that warning if you want to load from disk
Speaking of formatting code in place via "swift-format", when would I need Xcode plugin instead of a build phase (e.g. as done here, changing the formatting string from lint to format --in-place and moving the build phase to happen before "Compile Sources"?
These are the ones I don't know yet and would love an answer to. From my tests, both "lint" and "format" could be done either as a build phase or in Xcode plugin.
Yeah, they are different. Some things you could both "lint" (show warnings about) and "format" (autocorrect), while some other things you could only "lint" (show warnings about).