/x-swiftformat

X-SwiftFormat extension for Xcode

Primary LanguageSwiftOtherNOASSERTION

๐Ÿ›  X-SwiftFormat

Installation

Using Github

Using Cask

brew install --cask x-swiftformat

Usage

1) Open X-SwiftFormat

X-SwiftFormat works as Xcode Extension to format your swift code. You will need to open this once to activate it ๐Ÿ‘

a) You case use the Preview to see the format running in the app ๐Ÿ’ช

b) You can export a configuration file ( .swift-format ) to use later ๐Ÿ–ฅ

2) Enable X-SwiftFormat

Open System Preferences โ–ธ Extensions โ–ธ Xcode Source Editor and make sure X-SwiftFormat is selected โœ…

3) Use X-SwiftFormat

Open Xcode and use the Format Swift Code command in Xcode's Editor menu ๐Ÿš€

4) Add X-SwiftFormat Shortcut

Open System Preferences, click on Keyboard and switch to the Shortcuts tab. Select App Shortcuts, then hit the + button. Select Xcode, enter Format Swift Code and set your Shortcut.๐Ÿ‘


Installing Apple Swift Format (Xcode or Mint)

a) Using Xcode

if you are using Xcode 13.4 (Swift 5.6), you can check out and build swift-format using the following commands:

git clone -b release/5.6 https://github.com/apple/swift-format.git
cd swift-format
swift build

You should see this

Build complete! (51.82s)

๐Ÿ‘๐Ÿ‘๐Ÿ‘

b) Using Mint

If you dint have Homebrew, install here

brew install mint
mint install apple/swift-format@release/5.6

You should see this

๐ŸŒฑ Cloning swift-format release/5.6
๐ŸŒฑ Resolving package
๐ŸŒฑ Building package
๐ŸŒฑ Installed swift-format release/5.6
๐ŸŒฑ Linked swift-format release/5.6

๐Ÿ‘๐Ÿ‘๐Ÿ‘

Command Line Usage

swift-format -v
0.50600.1
Command Description
swift-format swift Display formatted code
swift-format -i file.swift Overwrites formatted code
swift-format -r folder Format all files in a folder
swift-format -r -i folder Format all files in a folder and overwrites

Check more info here: https://github.com/apple/swift-format


I'm Rui Aureliano, iOS and macOS Engineer at Olรก Brothers. We make Sip ๐Ÿค“

Linkedin | AngelList | Twitter | Github | Medium | Stackoverflow