Closed andrewdmontgomery closed 2 months ago
After a Slack discussion, I think moving the --swiftversion
into the .swiftformat
file (and dropping the .swift-version
file) makes sense. From the SwiftFormat README.md:
Most SwiftFormat rules are version-agnostic, but some are applicable only to newer Swift versions. These rules will be disabled automatically if the Swift version is not specified, so to make sure that the full functionality is available you should specify the version of Swift that is used by your project.
In practice, we will only need to change this when we update SwiftFormat (which may contain new rules for newer versions of Swift). So it really is a configuration setting for SwiftFormat, and there is no useful reason to keep it in sync with CocoaPods.
Why did CocoaPods move away from using the .swift-version
file? They dropped it when they introduced Multiple Swift Versions Support:
Note: While the pod author was initially allowed to publish their podspec using .swift-version file or --swift-version parameter, neither of them are preserved when a consumer is integrating their pod, therefore it is imperative to motivate pod authors to update their podspec to use the swift_versions DSL going forward.
So we really do want to specify it in the podspec.
I've also updated the podspecs to use the swift_versions = ['5.10']
syntax, in order to make it explicit that we can support multiple versions of Swift via CocoaPods.
So for example, if in the future, we retain support for Swift 5.10 (e.g. we leave the Package.swift configured with // swift-tools-version: 5.10
), then we could expand CocoaPods to support additional versions of Swift.
@pinarol does this all seem good to you? I know we originally discussed putting the .swift-version
file back. But I believe this makes more sense.
Closes #306
Description
This resolves a few warnings that are appearing in the output of running
swiftformat
(see issue #306)Where should we record the version?
SwiftFormat wants us to specify the version of Swift to use (SwiftFormat docs). It prefers to find that version in a
.swift-version
file. But we removed it in #285 . In this PR, I've moved that into the.swiftformat
file. But I worry about missing this configuration setting the next time we update the version of Swift.Thoughts? Perhaps this is a good reason to create documentation around the process of updating Xcode. If we did that, keeping this setting in the
.swiftformat
file would be a safe choice.Testing Steps
make swiftformat
and observe that there are no warnings (see issue #306 for examples)make lint
and observe that there are no warnings there either