sort-swift-imports

1.1.1-27

Sort import statements in your Swift source code.
darrarski/sort-swift-imports

What's New

v1.1.1 (27)

2024-05-13T21:40:37Z

What's Changed

New Contributors

Full Changelog: v1.0.0-6...v1.1.1-27

Sort (Swift) Imports

Swift 5.10 platform macOS iOS

Sort import statements in your Swift source code.

🏛 Swift Library

Add sort-swift-imports package dependency to your Swift Package:

.package(
  url: "https://github.com/darrarski/sort-swift-imports.git",
  from: "1.0.0"
),

Add SortSwiftImports library as a dependency to your targets:

.product(
  name: "SortSwiftImports", 
  package: "sort-swift-imports"
),

Use SortSwiftImports from your code:

import SortSwiftImports

let sortSwiftImports: SortSwiftImports = .live
let code: String = // swift source code
let result = sortSwiftImports(in: code)
switch result {
case let .success(output):
  print(output)
case let .failure(error):
  print(error)
}

🅰️ macOS application

Download on the App Store

Native SwiftUI macOS application that you can use to sort imports in your Swift source code. Just paste your code and click the Sort swift imports button.

It also contains Xcode Source Editor extensionso that you can sort your Swift imports directly from Xcode. Ensure you have enabled Sort Imports extension in System PreferencesExtensionsXcode Source Editor.

macOS
macOS app screenshot light modemacOS app screenshot dark mode

🅰️ iOS application

Download on the App Store

Native SwiftUI iOS application that you can use to sort imports in your Swift source code. Just paste your code and tap ⚙️Sort swift imports.

On your iPad, you can use multiple windows of the app simultaneously.

iPhone iPad
iPhone app screenshot light modeiPhone app screenshot dark mode iPad app screenshot light modeiPad app screenshot dark mode

🛠 Development

Open SortSwiftImports.xcworkspace in Xcode (⩾15.4) for development.

🧰 Workspace structure

SortSwiftImports (Xcode Workspace)
 ├─ sort-swift-imports (Swift Package)
 │   └─ SortSwiftImports (Library)
 ├─ sort-swift-imports-app (Swift Package)
 │   ├─ AppFeature (Library)
 │   └─ EditorFeature (Library)
 ├─ sort-swift-imports-app-icon (Swift Package)
 │   ├─ AppIcon (Library)
 │   └─ AppIconExport (macOS executable)
 └─ Project (Xcode Project)
     ├─ SortSwiftImportsApp (iOS and macOS Application)
     └─ SortSwiftImportsXcodeExtension (Xcode Source Editor Extension)

▶️ Build schemes

  • Use SortSwiftImportsApp scheme to build, run, and test the application on iOS and macOS.
  • Use SortSwiftImportsXcodeExtension scheme to build and run the Xcode Source Editor Extension.
  • Use AppIcon scheme for building & previewing the app icon in Xcode (use macOS destination).
  • Use ExportAppIcon scheme for exporting the app icon into asset catalog (use macOS destination).

Use other schemes for building and testing individual feature-libraries in isolation.

🙋‍♂️ Contributing

  • All contributions are welcome!
  • Create a pull request containing your changes or bug fixes.
  • Make sure to add tests for the new/updated code.

☕️ Do you like the project?

Buy Me A Coffee

Consider supporting further development and buy me a coffee.

 

📄 License

Copyright © 2021 Dariusz Rybicki Darrarski

License: MIT

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Dec 28 2024 22:18:30 GMT-1000 (Hawaii-Aleutian Standard Time)