Skip to content

Script to be used as a Succeeds post action to trigger SwiftLint when compiling a Swift Package

License

Notifications You must be signed in to change notification settings

Timac/SwiftLint-x-SwiftPackage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SucceedsPostAction.sh

SucceedsPostAction.sh is a bash script to be used as a 'Succeeds' post action in Xcode. This convenient script will automatically trigger SwiftLint when you compile a Swift Package.

Why?

At the moment you can't easily trigger SwiftLint when compiling a Swift Package. Swift 5.6 (not yet available at this time) might help thanks to SE-0303: Package Manager Extensible Build Tools. This script can be used in the meantime to help develop your Swift packages.

Requirements

  • Xcode 13.0 or later
  • SwiftLint installed at /usr/local/bin/swiftlint

Installation

  1. Download the script SucceedsPostAction.sh on your Mac.
  2. Ensure that the script has the proper permissions, i.e. run chmod 755 SucceedsPostAction.sh.
  3. If you want to use custom SwiftLint rules, add the .swiftlint.yml file next to the script.
  4. Launch Xcode 13.0 or later
  5. Open Preferences > Locations and ensure that Command Line Tools is set to an Xcode version
  6. Open Preferences > Behaviors > Succeeds
  7. Choose the script SucceedsPostAction.sh

That's it: each time you compile a Swift Package, the SucceedsPostAction.sh will run SwiftLint.

Demo

Limitations

A post action script running in Xcode can't add a log, a warning or an error to the Xcode build results. As a consequence, SucceedsPostAction.sh opens a text file as a new window in Xcode with the list of SwiftLint reports. There is no deep integration to easily jump to the SwiftLint warnings. Once SE-0303: Package Manager Extensible Build Tools is integrated, this script shouldn't be needed anymore.

Looking for a job?

Eimy is looking for SwiftUI experts to grow our truly usable consumer products team:

  • ❤️ SwiftUI
  • 🤓 State-of-the-art apps
  • ✨ Innovative consumer products
  • 🛠 Experienced team
  • 📍 Munich, Germany

👉 https://www.geteimy.com/jobs

About

Script to be used as a Succeeds post action to trigger SwiftLint when compiling a Swift Package

Resources

License

Stars

Watchers

Forks

Languages