You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
flutter_plugins supports Dart, Java, and Objective-C formatting. Since we'll be using Swift preferentially for macOS plugins (and probably someday for iOS, even if not yet), we should add support for swift-format too. (There are several Swift formatters, but based on internal discussions that's the one we should use.)
It's a bit fiddly to set up at the moment, but we should at least check if it's on the path and run it if so.
Yes, but it looks like it's resolved now! That "Note" section was only added a couple of days ago, and unless I'm misreading it, it's saying we won't have this problem going forward.
Are we using, or plan to use different versions of Swift for different plugins.
The problem was that the version they were referring to there wasn't the Swift syntax version, it was the swift toolchain version. Meaning that it used to be the case that you had to build the specific version of the former for the exact version of Xcode you had. So any time we wanted to update Xcode we would have had to update the formatter. And if there wasn't a formater version yet, we would actually be blocked from updating Xcode temporarily.
(And anyone wanting to format locally would have had to figure all of this out as well, to get and build just the right version.)
In case it's helpful, if you also contribute to the flutter engine, there is an issue with the swift-format under depot_tools. The current workaround is to install and run swift-format on your local machines (swift-format format -i -r /path/to/your/code).
Make sure to set up the export path properly to run your own copy of swift-format instead of the one under depot_tools.
Understood. The version we easily have available to us in CI from chromium is only built for Mac. I'd rather rearrange our test than maintain our own versions of this package, if possible.
🤦🏻 I forgot to check non-Flutter packages. Thanks for finding that!
We could make check_podspecs into a more generic repo_checks that also calls swift-format (it runs really fast).
Agreed, I was just looking at your other PR and wondering if we should combine it with something else.
We'll probably want to adjust the tooling to allow disabling formatting of each language so that we don't have two failures every time file in any other language fails, but I can add that easily. I'll take a look next week.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
stuartmorgan-g commentedon Sep 8, 2022
Actually running this in CI is still problematic:
cyanglaz commentedon Sep 22, 2022
Now that we are migrating iOS to swift, we may want to consider bumping up the priority of this?
Can you explain more about this? What is the "project"?
Did you mean https://github.com/apple/swift-format#matching-swift-format-to-your-swift-version-swift-57-and-earlier. Are we using, or plan to use different versions of Swift for different plugins. Can we query the swift version used in build setting and download the formatter accordingly?
stuartmorgan-g commentedon Sep 22, 2022
That was referring to apple/swift-format.
Yes, but it looks like it's resolved now! That "Note" section was only added a couple of days ago, and unless I'm misreading it, it's saying we won't have this problem going forward.
The problem was that the version they were referring to there wasn't the Swift syntax version, it was the
swifttoolchain version. Meaning that it used to be the case that you had to build the specific version of the former for the exact version of Xcode you had. So any time we wanted to update Xcode we would have had to update the formatter. And if there wasn't a formater version yet, we would actually be blocked from updating Xcode temporarily.(And anyone wanting to format locally would have had to figure all of this out as well, to get and build just the right version.)
jmagman commentedon Sep 22, 2022
It also says swift-format can be used as an API from another swift script, as opposed to using it as a command line tool https://github.com/apple/swift-format#api-usage. That would allow us to use Swift Package Manager to manage the version resolution. That may be easier than building from source https://github.com/apple/swift-format#getting-swift-format
[-]Add support for swift-format[/-][+][plugins] Add support for swift-format[/+]hellohuanlin commentedon Jan 23, 2023
In case it's helpful, if you also contribute to the flutter engine, there is an issue with the swift-format under depot_tools. The current workaround is to install and run swift-format on your local machines (
swift-format format -i -r /path/to/your/code).Make sure to set up the export path properly to run your own copy of swift-format instead of the one under depot_tools.
[-][plugins] Add support for swift-format[/-][+][packages] Add support for swift-format[/+]stuartmorgan-g commentedon Jul 6, 2023
Now that we're using LUCI, we could probably just by making a cipd package of swift-format, and add it to the dependencies in
.ci.yaml.10 remaining items
Gustl22 commentedon Jan 13, 2024
swift-format also works on Ubuntu, but not on Alpine, e.g. https://hub.docker.com/r/mtgto/swift-format/
jmagman commentedon Jan 13, 2024
Understood. The version we easily have available to us in CI from chromium is only built for Mac. I'd rather rearrange our test than maintain our own versions of this package, if possible.
stuartmorgan-g commentedon Jan 13, 2024
🤦🏻 I forgot to check non-Flutter packages. Thanks for finding that!
Agreed, I was just looking at your other PR and wondering if we should combine it with something else.
We'll probably want to adjust the tooling to allow disabling formatting of each language so that we don't have two failures every time file in any other language fails, but I can add that easily. I'll take a look next week.
Sort Swift imports in templates (#141487)
[ci] Add flags to formatter command to decide which formatters to run (…
[ci] Run Swift formatter and linter during CI formatting (#5928)
[pigeon] Support other hosts in generated file CI checks (#5944)
github-actions commentedon Feb 2, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.[ci] Run Swift formatter and linter during CI formatting (flutter#5928)
[ci] Run Swift formatter and linter during CI formatting (flutter#5928)