Skip to content

[action][swiftlint] Fix path option for SwiftLint 0.48.0 and above#30080

Merged
iBotPeaches merged 3 commits into
fastlane:masterfrom
augustocbx:issue-22191
Jun 24, 2026
Merged

[action][swiftlint] Fix path option for SwiftLint 0.48.0 and above#30080
iBotPeaches merged 3 commits into
fastlane:masterfrom
augustocbx:issue-22191

Conversation

@augustocbx

@augustocbx augustocbx commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🔑

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Motivation and Context

Resolves #22191
Resolves #22063
Closes #22124

SwiftLint deprecated the --path flag in 0.48.0 and newer releases reject it outright, so any lane using swiftlint(path: ...) fails with Error: Unknown option '--path'.

Description

The swiftlint action always appended --path <path> to the command, regardless of the installed SwiftLint version. Since SwiftLint replaced --path with a positional path argument in 0.48.0, the emitted command became invalid on current SwiftLint installs.

The action now version-gates how the path is passed: it keeps --path <path> for SwiftLint below 0.48.0 and passes the path as a positional argument (swiftlint lint <path>) for 0.48.0 and above. Existing behavior for older versions is unchanged, and the path is still shell-escaped in both cases.

Testing Steps

  • bundle exec rspec fastlane/spec/actions_specs/swiftlint_spec.rb
  • bundle exec rubocop fastlane/lib/fastlane/actions/swiftlint.rb fastlane/spec/actions_specs/swiftlint_spec.rb

New specs assert that for SwiftLint 0.48.0 and above the command is swiftlint lint <path> (no --path) and that spaces in the path are still escaped. The existing example pinning --path for older versions remains green.

SwiftLint removed the `--path` flag in 0.48.0, so `swiftlint(path:)`
failed with `Unknown option '--path'` on newer versions. The action now
passes the path as a positional argument for SwiftLint 0.48.0 and above,
while still emitting `--path` for older versions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the swiftlint action to remain compatible with SwiftLint 0.48.0+, where the --path flag was removed and paths must be passed positionally.

Changes:

  • Version-gates how path is passed to SwiftLint (--path <path> for < 0.48.0; positional <path> for >= 0.48.0).
  • Adds specs covering the new positional path behavior and shell-escaping for paths containing spaces.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
fastlane/lib/fastlane/actions/swiftlint.rb Adds path_argument helper and switches path handling based on SwiftLint version.
fastlane/spec/actions_specs/swiftlint_spec.rb Adds new specs for SwiftLint >= 0.48.0 positional path behavior and escaping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fastlane/lib/fastlane/actions/swiftlint.rb
Comment thread fastlane/spec/actions_specs/swiftlint_spec.rb
@iBotPeaches

Copy link
Copy Markdown
Member

thanks! Added Copilot and edited a few more bugs/PRs to close on merge of this.

Addresses review feedback: SwiftLint usage is `lint [<options>] [<paths> ...]`, so the positional path must come after the option flags. Adds a spec asserting path ordering relative to --strict.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread fastlane/lib/fastlane/actions/swiftlint.rb Outdated
Addresses review feedback: append the positional path in run() after the --use-script-input-files flag so it stays the last swiftlint argument when both :path and :files are used. Adds a spec covering that ordering.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@iBotPeaches iBotPeaches merged commit 9ba30b9 into fastlane:master Jun 24, 2026
12 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @augustocbx 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a month, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀"

This was referenced Jul 4, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations! 🎉 This was released as part of fastlane 2.237.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants