'How do I prevent xcode from editing the code

Xcode lately is rewriting some code source, say empty function on occation is rewritten as {}, etc. It's absolutely infuriating. How to prevent xcode from editing the code behind my back?



Solution 1:[1]

This is often a side effect of an automatic code formatting.

Tools like SwiftFormat often get invoked as a build step before compilation to ensure consistent code formatting among all team members.

Another drawback of this method is a lost undo history when a file gets reformatted, but from my experience, pros of autoformatting outweigh the cons even in a one person team.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vadim Belyaev