-
Notifications
You must be signed in to change notification settings - Fork 206
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
[iOS]Introduce swift-format #801
Conversation
This reverts commit 7ae4c51.
# Conflicts: # app-ios/Modules/Package.swift
app-ios/Modules/Package.swift
Outdated
@@ -20,9 +20,10 @@ var package = Package( | |||
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.4"), | |||
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"), | |||
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "0.1.0"), | |||
.package(url: "https://github.com/realm/SwiftLint", from: "0.52.4"), | |||
.package(url: "https://github.com/realm/SwiftLint", from: "0.51.0"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following error occurred:
Failed to resolve dependencies Dependencies could not be resolved because root depends on 'swiftlint' 0.52.4..<1.0.0 and root depends on 'swift-format' 508.0.0..<509.0.0.
'swiftlint' is incompatible with 'swift-format'.
'swiftlint' >= 0.52.4 practically depends on 'swift-syntax' 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-04-a because 'swiftlint' 0.52.4 depends on 'swift-syntax' 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-04-a and no versions of 'swiftlint' match the requirement 0.52.5..<1.0.0.
'swift-format' >= 508.0.0 practically depends on 'swift-syntax' 508.0.0..<509.0.0 because 'swift-format' 508.0.0 depends on 'swift-syntax' 508.0.0..<509.0.0 and 'swift-format' 508.0.1 depends on 'swift-syntax' 508.0.0..<509.0.0.
'swift-format' {508.0.0, 508.0.2..<509.0.0} practically depends on 'swift-syntax' 508.0.0..<509.0.0 because no versions of 'swift-format' match the requirement 508.0.2..<509.0.0 and 'swift-format' 508.0.0 depends on 'swift-syntax' 508.0.0..<509.0.0.
From this, I belive we either need to upgrade the version of swift-format or downgrade the version of SwiftLint to match the version of swift-syntax.
However, since the current latest version of swift-format is 508.0.1 and cannot be raised any further, I downgraded the SwiftLint version to 51.0.
日本語
以下のようなエラーが発生しました。Failed to resolve dependencies Dependencies could not be resolved because root depends on 'swiftlint' 0.52.4..<1.0.0 and root depends on 'swift-format' 508.0.0..<509.0.0.
'swiftlint' is incompatible with 'swift-format'.
'swiftlint' >= 0.52.4 practically depends on 'swift-syntax' 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-04-a because 'swiftlint' 0.52.4 depends on 'swift-syntax' 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-04-a and no versions of 'swiftlint' match the requirement 0.52.5..<1.0.0.
'swift-format' >= 508.0.0 practically depends on 'swift-syntax' 508.0.0..<509.0.0 because 'swift-format' 508.0.0 depends on 'swift-syntax' 508.0.0..<509.0.0 and 'swift-format' 508.0.1 depends on 'swift-syntax' 508.0.0..<509.0.0.
'swift-format' {508.0.0, 508.0.2..<509.0.0} practically depends on 'swift-syntax' 508.0.0..<509.0.0 because no versions of 'swift-format' match the requirement 508.0.2..<509.0.0 and 'swift-format' 508.0.0 depends on 'swift-syntax' 508.0.0..<509.0.0.
このことから、swift-format のバージョンを上げるか、SwiftLintのバージョンを下げないと、SwiftSyntac のバージョンに合わせることができないと思います。
しかし、swift-format の現在の最新バージョンは 508.0.1 でこれ以上上げることができないので、SwiftLintのバージョンを51.0までバージョンを下げました。
app-ios/Modules/Package.swift
Outdated
@@ -209,6 +210,7 @@ package.targets = package.targets.map { target -> Target in | |||
target.plugins = [] | |||
} | |||
target.plugins?.append(.plugin(name: "SwiftLintPlugin", package: "SwiftLint")) | |||
target.plugins?.append(.plugin(name: "SwiftFormatPlugin", package: "swift-format")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SwiftFormatPlugin
isn't a correct name 🙏🏼
Please use FormatPlugin
🙏🏼
https://github.com/apple/swift-format/blob/508.0.1/Package.swift#L37
And format or format-lint isn't succeeded. Can you check it? 🙇🏼
The current swift-format doesn't seem to provide any build tools, so adding it to targets as a plugin may not work. |
@woxtu As long as SwiftLint is present, the command plugin didn't work either. Below is the error message I received at that time: error: Dependencies could not be resolved because root depends on 'swiftlint' 0.52.4..<1.0.0 and root depends on 'swift-format' 508.0.1..<509.0.0.
'swift-format' is incompatible with 'swiftlint' because 'swiftlint' 0.52.4 depends on 'swift-syntax' 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-04-a and no versions of 'swiftlint' match the requirement 0.52.5..<1.0.0.
'swift-format' >= 508.0.1 practically depends on 'swift-syntax' 508.0.0..<509.0.0 because no versions of 'swift-format' match the requirement 508.0.2..<509.0.0 and 'swift-format' 508.0.1 depends on 'swift-syntax' 508.0.0..<509.0.0. Thus, by removing SwiftLint and introducing it as a command plugin, it worked without any issues. However, it only formats a portion of the code.
日本語[Package 内へのファイル書き込みができない](https://qiita.com/maiyama18/items/3d0f7b288c6858b751ce#package-%E5%86%85%E3%81%B8%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E6%9B%B8%E3%81%8D%E8%BE%BC%E3%81%BF)のは初めて知りました。ありがとうございます🎉SwiftLintがある以上、コマンドプラグインでも動作しませんでした。以下はその時に出たエラー文です。 error: Dependencies could not be resolved because root depends on 'swiftlint' 0.52.4..<1.0.0 and root depends on 'swift-format' 508.0.1..<509.0.0.
'swift-format' is incompatible with 'swiftlint' because 'swiftlint' 0.52.4 depends on 'swift-syntax' 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-07-04-a and no versions of 'swiftlint' match the requirement 0.52.5..<1.0.0.
'swift-format' >= 508.0.1 practically depends on 'swift-syntax' 508.0.0..<509.0.0 because no versions of 'swift-format' match the requirement 508.0.2..<509.0.0 and 'swift-format' 508.0.1 depends on 'swift-syntax' 508.0.0..<509.0.0. なので、SwiftLintを抜いて、コマンドプラグインとして導入したら問題なく動作しました。 ただ、一部のコードしかformatしてくれないです。
|
Issue
Overview (Required)
I'm still unfamiliar with how to incorporate iOS libraries in KMM, so I'm a bit unsure if this is correct... 😥
日本語
- [Swift-format](https://github.com/apple/swift-format) の導入 私はまだKMMにおいて、iOSのライブラリを入れる方法の仕方について知見がないため、この内容で合っているのか少し不安です😥Links
Screenshot