Latest release of Xcode (4.5) is supposed to strip trailing whitespace from source files.
But when I save a file with some spaces at the end of a line they're still there.
What am I missing?
OK, here's what the problem was.
Xcode will not trim trailing white space if you add a white space at the end of the line, leave the cursor at the end of that line and then save it.
You need to move your cursor off that line and then save it.
May be some conflict between saving the position of the cursor whilst simultaneously trimming the whitespace perhaps?
Yes, committing Xcode edited code shows trailing white-spaces in Git. Going into Xcode preferences > Text Editing : Editing (tab), you have option to include whitespaces-only lines.
Worth to mention my current Xcode version v5.1.
Now, what about code that already uploaded in git which complaints about whitespaces?
Well, find in your editor for 4 spaces (By default in Xcode preferences > Text Editing > Indentation, indent set with 4 spaces which also can be changed ); and replace with empty string manually for those without any code in the line. You may further copy paste code in other editor (for eg TextWrangler) to see if any empty line left with 4 spaces only. "Cmd + G" is short key to "find next", helps while iterating.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With