Convert Figma logo to code with AI

Jintin logoSwimat

An Xcode formatter plug-in to format your swift code.

1,647
89
1,647
24

Top Related Projects

A command-line tool and Xcode Extension for formatting Swift code

18,578

A tool to enforce Swift style and conventions.

2,271

A package manager that installs and runs executable Swift packages

Simple macOS editor app to help you manage iOS and macOS app localizations by allowing you to edit all the translations side by side

9,488

Strong typed, autocompleted resources like images, fonts and segues in Swift projects

Quick Overview

Swimat is an Xcode plugin and command-line tool designed to format Swift code automatically. It aims to improve code readability and consistency by applying a set of predefined formatting rules to Swift source files.

Pros

  • Improves code readability and consistency across projects
  • Saves time by automating the code formatting process
  • Supports both Xcode integration and command-line usage
  • Customizable formatting options to suit different coding styles

Cons

  • May not cover all edge cases or complex code structures
  • Requires manual installation for Xcode integration
  • Limited documentation and community support
  • Not actively maintained (last update was in 2019)

Code Examples

  1. Basic usage as a command-line tool:
swimat /path/to/your/swift/file.swift

This command will format the specified Swift file in place.

  1. Using Swimat with input/output files:
swimat -i input.swift -o output.swift

This example reads the input.swift file, formats its contents, and writes the result to output.swift.

  1. Formatting an entire directory:
swimat -p /path/to/your/project

This command recursively formats all Swift files in the specified directory.

Getting Started

To use Swimat as a command-line tool:

  1. Install Swimat using Homebrew:

    brew install swimat
    
  2. Format a Swift file:

    swimat /path/to/your/swift/file.swift
    

To integrate Swimat with Xcode:

  1. Download the latest release from the GitHub repository.
  2. Unzip the file and copy Swimat.app to your Applications folder.
  3. Run Swimat.app and follow the prompts to integrate it with Xcode.
  4. Restart Xcode and use the Editor > Swimat > Format menu item to format your code.

Competitor Comparisons

A command-line tool and Xcode Extension for formatting Swift code

Pros of SwiftFormat

  • More comprehensive formatting options, covering a wider range of Swift code style rules
  • Actively maintained with frequent updates and improvements
  • Supports command-line usage, Xcode integration, and various build systems

Cons of SwiftFormat

  • Slower performance compared to Swimat, especially for large codebases
  • More complex configuration options, which may be overwhelming for some users

Code Comparison

SwiftFormat:

let example = [1, 2, 3]
    .map { $0 * 2 }
    .filter { $0 > 2 }

Swimat:

let example = [1, 2, 3]
  .map { $0 * 2 }
  .filter { $0 > 2 }

SwiftFormat offers more granular control over formatting, such as adjusting indentation and line breaks. Swimat provides a simpler, more opinionated approach to formatting.

Both tools aim to improve Swift code readability and consistency, but SwiftFormat offers more flexibility and features at the cost of increased complexity. Swimat, while simpler, may be sufficient for many projects and offers faster performance. The choice between the two depends on specific project requirements and team preferences.

18,578

A tool to enforce Swift style and conventions.

Pros of SwiftLint

  • More comprehensive linting capabilities, covering a wide range of Swift coding style and conventions
  • Highly customizable with numerous configuration options and the ability to create custom rules
  • Active development and maintenance with frequent updates and a large community

Cons of SwiftLint

  • Steeper learning curve due to its extensive feature set and configuration options
  • Can be resource-intensive for large projects, potentially slowing down the development process

Code Comparison

SwiftLint example:

let myArray = [1, 2, 3]
// SwiftLint warning: Collection literals should not have trailing commas.
let myDictionary = ["key": "value",]

// SwiftLint error: Line should be 120 characters or less: currently 121 characters
let longLine = "This is a very long line that exceeds the default line length limit set by SwiftLint, which is typically 120 characters."

Swimat example:

let myArray = [1, 2, 3]
let myDictionary = ["key": "value"]

// Swimat focuses on formatting, not linting
let longLine = "This is a very long line that Swimat would format but not flag as an error or warning."

Note: Swimat is primarily a code formatter, while SwiftLint is a linter. Their functionalities differ, with SwiftLint providing more extensive code analysis and style checking.

2,271

A package manager that installs and runs executable Swift packages

Pros of Mint

  • More comprehensive package management features, including dependency resolution and version control
  • Supports multiple package sources, including GitHub and custom URLs
  • Actively maintained with regular updates and improvements

Cons of Mint

  • More complex setup and usage compared to Swimat's straightforward formatting approach
  • Requires additional configuration and management for package dependencies
  • May have a steeper learning curve for users new to package management tools

Code Comparison

Swimat (formatting Swift code):

let example = [1,2,3,4]
func doSomething(   with: String   ) {
    print("Hello, \(with)!")
}

Mint (installing a package):

mint install realm/SwiftLint
mint run SwiftLint

While Swimat focuses on code formatting, Mint is a package manager that handles installation and execution of Swift command-line tools. The code examples demonstrate their different purposes and usage patterns.

Simple macOS editor app to help you manage iOS and macOS app localizations by allowing you to edit all the translations side by side

Pros of iOSLocalizationEditor

  • Focuses specifically on iOS localization, providing a dedicated tool for managing language strings
  • Offers a user-friendly graphical interface for editing localization files
  • Supports multiple languages and allows easy addition of new translations

Cons of iOSLocalizationEditor

  • Limited to iOS localization tasks, not a general-purpose code formatting tool
  • May require more setup and integration compared to a simple command-line formatter
  • Potentially less flexible for customizing formatting rules

Code Comparison

While a direct code comparison isn't particularly relevant due to the different purposes of these tools, we can look at how they might be used:

Swimat (command-line usage):

swimat /path/to/your/swift/file.swift

iOSLocalizationEditor (typical workflow):

// Load localization files
let editor = LocalizationEditor()
editor.loadFiles(from: "/path/to/your/project")

// Edit translations
editor.addTranslation(key: "greeting", value: "Hello", language: "en")

// Save changes
editor.saveChanges()

Note that iOSLocalizationEditor is typically used through its GUI, so the code example is more illustrative of its functionality rather than actual usage.

9,488

Strong typed, autocompleted resources like images, fonts and segues in Swift projects

Pros of R.swift

  • Generates strongly typed resources for Swift projects, improving code safety and autocomplete
  • Supports a wide range of resource types, including images, fonts, colors, and localized strings
  • Integrates well with Xcode and CocoaPods for easy setup and usage

Cons of R.swift

  • Limited to Swift projects, while Swimat supports both Swift and Objective-C
  • Requires additional build steps and may increase compilation time
  • More complex setup compared to Swimat's simple installation process

Code Comparison

R.swift:

let image = R.image.backgroundImage()
let font = R.font.helveticaNeue(size: 16)
let color = R.color.primaryColor()
let string = R.string.localizable.welcomeMessage()

Swimat:

// Swimat doesn't generate code, it formats existing code
let image = UIImage(named: "backgroundImage")
let font = UIFont(name: "HelveticaNeue", size: 16)
let color = UIColor(named: "primaryColor")
let string = NSLocalizedString("welcomeMessage", comment: "")

R.swift focuses on generating type-safe accessors for resources, while Swimat is primarily a code formatter. R.swift provides stronger compile-time checks and autocompletion, but requires more setup and is specific to Swift projects. Swimat, on the other hand, offers a simpler solution for code formatting across both Swift and Objective-C codebases.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Swimat

Build Status Codacy Badge Awesome

github homebrew-cask

Swimat is an Xcode plug-in to format your Swift code.

Preview

Installation

There are three way to install.

  1. Install via homebrew-cask
# Homebrew previous version
brew cask install swimat
# Homebrew latest version
brew install --cask swimat
  1. Download the App directly.
    https://github.com/Jintin/Swimat/releases/download/1.7.0/Swimat.zip

  2. Clone and archive to Mac App by yourself.

Usage

After installation, you should open the Swimat.app once to make the functionality works.

In the Xcode menu click [Editor] -> [Swimat] -> [Format] then the current active file will reformat.

You can also create a hot-key in [Xcode] -> [Preferences..] -> [Key Bindings], if you don't have any prefernce you can set as ⌘ + ⇧ + L.

TroubleShooting

Check [System Preferences] -> [Extensions] -> [Xcode Source Editor] -> [Swimat] is checked.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Jintin/Swimat.

License

The module is available as open source under the terms of the MIT License.