Skip to content

About

X-SwiftFormat extension for Xcode

Topics

Resources

Stars

779 stars

Watchers

13 watching

Forks

Latest commit

 

History

123 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛠 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 👍

xsf-running-light xsf-running-light

a) You case use the Preview to see the format running in the app 💪

xsf-format-light xsf-format-light

b) You can export a configuration file ( .swift-format ) to use later 🖥

2) Enable X-SwiftFormat

Open System Preferences ▸ Privacy & Security ▸ Extensions ▸ Xcode Source Editor and make sure X-SwiftFormat is selected ✅

xsf-extensions-light xsf-extensions-light

3) Use X-SwiftFormat

Open Xcode and use the Format Swift Code command in Xcode's Editor menu 🚀

xsf-usage-light xsf-usage-light

4) Add X-SwiftFormat Shortcut

Open System Preferences ▸ PKeyboard ▸ Keyboard Shortcuts ▸ App Shortcuts, then hit the + button. Select Xcode, enter Format Swift Code and set your Shortcut.👏

xsf-shortcuts-light xsf-shortcuts-light


Installing Apple Swift Format (Xcode or Mint)

a) Using Xcode

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

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

You should see this

Build complete! (50.00s)

👍👍👍

b) Using Mint

If you did not have Homebrew, install here

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

You should see this

🌱 Cloning swift-format release/6.2
🌱 Resolving package
🌱 Building package
🌱 Installed swift-format release/6.2
🌱 Linked swift-format release/6.2

👍👍👍

Command Line Usage

swift-format -v
600.0.0
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 | Twitter | Github | Stackoverflow

About

X-SwiftFormat extension for Xcode

Topics

Resources

Stars

779 stars

Watchers

13 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages