Automatically align assignments (a la uncrustify) and other similar "inspections"

Is there a way to add a "hook" to the save action to run a custom shell script? The idea would be to run uncrustify every time I save a file. I could theoretically run the script using some fsevent file monitoring tool, but it would be more convenient if I could do that directly from appcode. Alternatively, even though that would not be ideal, is it possible to run a shell script everytime I build/run the app?


To answer the second part of your question: I'm not sure if there is a way to do it inside AppCode, but in Xcode you can add a "Run Script Build Phase" from the "Build Phases" panel that allows you to run arbitrary scripts during a build. The scripts should be run when building in AppCode.


Thanks for your answer. I might end up doing that, but I'm not sure it's a better solution than using a
file monitoring script.

It would be nice if there was this functionality built in AppCode, or even a plugin that can do that...


You can add an external (shell) tool that is run when you select it from the menu or the "Find Action" shortcut. It runs with the currently selected editor as the target and there are several convenience macros that will expand when it is run to give you the file's full path, containing folder, file extension, etc…

They can be configured under "Preferences > External Tools" and then click the "+" button to add a tool. External tools can be executed from the "Tools" menu under the group name that you gave it when you configured the tool.

Now the only thing missing is a hook to run the external tool when the file is saved.


Please sign in to leave a comment.