DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Michael Lustig - halfjew22@gmail.com
Michael Lustig - halfjew22@gmail.com

Posted on

Format Swift on Save - AppCode with swift-format

Coming from WebStorm and TypeScript land, I got sick of not having auto-formatted code while working on a small Front End SwiftUI project. After finally figuring out how to autoformat my Swift code, I had to share as NO RESULTS ONLINE WERE HELPFUL!

See below and linked video. Let me know if you have any questions or suggestions for improvements.

  1. brew install nshipster/formulae/swift-format
  2. Create external tool
  3. Name it swift-format
  4. Under Tool Settings > Arguments: --in-place $FilePath$
  5. Advanced Options > Uncheck Open console for tool output
  6. Click OK
  7. Click Apply
  8. Create a Keymap for your new external tool by searching for β€œswift-format” and double clicking on the result
  9. Open any code file
  10. Edit > Macros > Start Macro Recording
  11. Invoke the keycap from step 6 and then save your file
  12. Click the stop button in the bottom right hand of your editor to stop the macro
  13. LAST STEP Assign the ⌘S keymap to your new macro

Top comments (0)

Timeless DEV post...

How to write a kickass README

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

If you write a README without sufficient explanation of what your project does or how people can use it then it pretty much defeats the purpose of being open source as other developers are less likely to engage with or contribute towards it.