How to use code formatter in Xcode for Swift?

后端 未结 9 664
Happy的楠姐
Happy的楠姐 2021-01-31 07:25

Xcode code formatter Swift

I\'m trying to auto format my code written in Swift. It\'s necessary if you\'re working in team and using CVS and don\'t want

相关标签:
9条回答
  • 2021-01-31 08:07

    SwiftFormat is a popular code formatter for swift. It has an extension for Xcode, which can be accessed from the Editor menu.

    Quote from the SwiftFormat readme:

    SwiftFormat is a code library and command-line tool for reformatting swift code on macOS or Linux.

    SwiftFormat goes above and beyond what you might expect from a code formatter. In addition to adjusting white space it can insert or remove implicit self, remove redundant parentheses, and correct many other deviations from the standard Swift idioms.

    0 讨论(0)
  • 2021-01-31 08:08

    I write a extension app about format Swift code: Swimat

    There has two way to install

    1. brew cask install swimat

    2. Clone this repo, build and restart Xcode.

    See https://github.com/Jintin/Swimat for more information

    preview

    0 讨论(0)
  • 2021-01-31 08:12

    I would suggest using sublime text with the swift plugin, which will allow you to hotkey the code formatting. https://sublime.wbond.net/packages/Swift

    0 讨论(0)
提交回复
热议问题