By default Xcode not remove trailing whitespace from code, this gist will do it to you.
Copy remove-whitespaces.sh anywere you like in your Mac, and be sure to give it the execute permission.
Open XCode preferences
go to behaviors
:
Use +
sign to add new custom behavior name it with Strip Trailing Spaces
, feel free to name it as what you want. You also can create key binding for this custom behavior, i would like make it with ⌃⌥⌘S
.
Make Run
checkbox checked, browse where you place remove-whitespaces.sh file.
Go to menu XCode > Behaviors > Strip Trailing Spaces
or press ⌃⌥⌘S
to run script in your current project.
Enjoy