Does Xcode have code autoformat feature?

后端 未结 8 685
忘了有多久
忘了有多久 2021-01-30 10:09

Is any way to autoformat a source code in the Xcode IDE?

8条回答
  •  隐瞒了意图╮
    2021-01-30 10:37

    Format on Save

    For anyone wanting to format on save this is what I did. It's a bit janky but it works well. ⤵


    1. To get started pick out a formatter for Xcode. I'd recommend SwiftFormat but here's a list of a bunch of them and other handy extensions.
    2. Once you have a formatter picked out assign it a hotkey in Xcode that's not taken such as CMD + ~
    3. Then download a shortcut mapper such as BetterTouchTool.
    4. In your shortcut mapper simply setup CMD + S for Xcode and set it to actually use your shortcut you set for your fomatter. Like this ⤵

提交回复
热议问题