According to this site, text files (i.e. source code files) should always end in a new line. But Xcode (as of at least version 7.1) defaults to have no new line at the end of a file unless you explicitly put it there.

There are preferences to strip trailing whitespace and set the default line endings (all in “Xcode -> Preferences -> Text Editing”) but I can’t find a way to automatically add a new line at the end of each file. Can this be done in Xcode?


While this answer is written nearly a year after the question, I'll post it regardless for reference.

Xcode 8 and later automatically appends a newline to every saved text file if it didn't end with one. This includes files other than source code, like Markdown. There doesn't seem an option to disable this behaviour.

  • Thank you! I'd like to wait until it's released publicly before I accept it, but this is definitely the result I was looking for. – Edward Loveall Jul 20 '16 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.