https://github.com/ruiaureliano/X-SwiftFormat
X-SwiftFormat extension for Xcode
https://github.com/ruiaureliano/X-SwiftFormat
format swift xcode
Last synced: 3 months ago
JSON representation
X-SwiftFormat extension for Xcode
- Host: GitHub
- URL: https://github.com/ruiaureliano/X-SwiftFormat
- Owner: ruiaureliano
- License: other
- Created: 2020-03-29T11:27:38.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-04T14:06:59.000Z (about 1 year ago)
- Last Synced: 2024-08-01T19:57:49.105Z (11 months ago)
- Topics: format, swift, xcode
- Language: Swift
- Homepage:
- Size: 204 MB
- Stars: 770
- Watchers: 15
- Forks: 24
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# ๐ X-SwiftFormat
[](./LICENSE.md) [](https://swift.org/blog/swift-6.0-released/) [](./DOCS.md)

## Installation
### Using Github
[](https://github.com/ruiaureliano/X-SwiftFormat/releases/download/2.0.1/x-swiftformat_2.0.1.zip)
### 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** โธ **Privacy & Security** โธ **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** โธ **PKeyboard** โธ **Keyboard Shortcuts** โธ **App Shortcuts**, then hit the + button. Select **Xcode**, enter `Format Swift Code` and set your **Shortcut**.๐

---
# Installing [Apple Swift Format](https://github.com/apple/swift-format) (Xcode or Mint)
## a) Using Xcode
if you are using **Xcode 15 (Swift 6.0)**, you can check out and build swift-format using the following commands:
```
git clone -b release/6.0 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](https://brew.sh)
```
brew install mint
mint install apple/swift-format@release/6.0
```You should see this
```
๐ฑ Cloning swift-format release/6.0
๐ฑ Resolving package
๐ฑ Building package
๐ฑ Installed swift-format release/6.0
๐ฑ Linked swift-format release/6.0
```๐๐๐
### 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](https://github.com/apple/swift-format)
---
I'm [Rui Aureliano](http://ruiaureliano.com), iOS and macOS Engineer at [Olรก Brothers](https://theolabrothers.com). We make [Sip](https://sipapp.io) ๐ค
[Linkedin](https://www.linkedin.com/in/ruiaureliano) | [Twitter](https://twitter.com/ruiaureliano) | [Github](https://github.com/ruiaureliano) | [Stackoverflow](https://stackoverflow.com/users/881095/ruiaureliano)