Xcode should auto-format Swift on save
| Originator: | robnapier | ||
| Number: | rdar://17113086 | Date Originated: | 03-Jun-2014 08:54 AM |
| Status: | Open | Resolved: | |
| Product: | Xcode | Product Version: | 6 |
| Classification: | Reproducible: |
Xcode should, by default, apply a standard formatting (a la clang-format) to Swift source code when saved. Establishing from the beginning that there is a standard way to format Swift code can bypass many of the formatting collisions that have plagued other languages (both technical in version control, and inter-personal). The Go language has had very good luck with their "gofmt" tool, which has no options and establishes "correct" Go formatting. Many of their decisions are arbitrary (as formatting decisions often must be), but by picking a set for the language, they have greatly simplified these contentious issues. Tabs/Spaces. Brace placement. How things line up. Etc. (Note that the Go compiler, unlike Python, does not care about the formatting style. This is purely a matter of tools, not the compiler. The Swift *language* should not care about formatting except where required.) If Xcode does provide formatting options, then there should be a way to embed those options into the file (likely as a comment at the top or bottom) so that Xcode can still enforce consistent formatting on save. The most important part of this is that enforced formatting be on by default in Xcode for Swift projects. This will establish it early in the ecosystem and avoid organic growth of competing formatting styles.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!