• Stars
    star
    747
  • Rank 60,741 (Top 2 %)
  • Language
    Swift
  • License
    Other
  • Created over 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

X-SwiftFormat extension for Xcode

πŸ›  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 14 (Swift 5.7), you can check out and build swift-format using the following commands:

git clone -b release/5.7 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 did not have Homebrew, install here

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

You should see this

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

πŸ‘πŸ‘πŸ‘

Command Line Usage

swift-format -v
0.50700.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