Skip to content

[tool] Use swift-format from Xcode #9460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

stuartmorgan-g
Copy link
Contributor

As of Xcode 16, swift-format is part of the Xcode distribution. Since CI now uses Xcode 16, we can just always use that version.

This:

  • Removes the swift-format-path logic.
  • Removes the check for swift-format being available
  • Defaults Swift formatting to true only on macOS
  • Removes the swift-format CIPD package from .ci.yaml
  • Updates Pigeon in packages using Swift Pigeon generation to pick up a fix for a lint issue picked up by the latest version of swift-format (which was already fixed in Pigeon).

Fixes flutter/flutter#153803

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

@stuartmorgan-g
Copy link
Contributor Author

@jmagman / @vashworth Any objection to this approach of just unconditionally using xcrun, rather than using the multi-step check originally described in flutter/flutter#153803 ?

We could still do that version, if we wanted to support overriding the swift-format version (or to allow running swift-format from other platforms), but in practice I think that now that it's part of Xcode the chances that anyone will ever actually want to run a version that's not the Xcode version is very low, so probably not worth the complexity in the tool.

@@ -45,7 +45,7 @@ class SavePanelOptions {
/// Options for open panels.
///
/// These correspond to NSOpenPanel properties.
class OpenPanelOptions extends SavePanelOptions {
Copy link
Contributor Author

@stuartmorgan-g stuartmorgan-g Jun 20, 2025

Choose a reason for hiding this comment

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

This change preserves the old behavior. When I first wrote this I used inheritance out of habit, but that didn't actually do anything in Pigeon at the time. I fixed it by adding composition (line 62 below), but forgot to remove this extends that was being ignored.

In the current Pigeon this is an error, because inheritance does work, but only to inherit from a sealed empty base class to allow type switching.

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

Successfully merging this pull request may close these issues.

In packages repo, swift-format should fall back to Xcode swift-format if not found on PATH
1 participant