Repository navigation
Closed
Labels
discussionTopics that cannot be categorized as bugs or enhancements yet. They require further discussions.enhancementIdeas for improvements of existing features and rules.
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
try compiling a SwiftLint windows binary as there no windows instructions except compile from source
need help if anyone knows where the swift compiler compiles windows binaries if at all possible for swift project
such as this one can be compiled for windows
Complete output when running SwiftLint, including the stack trace and command used
this is the compilation output on windows
swift build -c release
Fetching https://github.com/jpsim/SourceKitten.git
Fetching https://github.com/apple/swift-argument-parser.git
Fetching https://github.com/scottrhoyt/SwiftyTextTable.git
warning: 'sourcekitten': skipping cache due to an error: Error Domain=NSCocoaErrorDomain Code=516 "A file with the same name already exists."
warning: 'swiftytexttable': skipping cache due to an error: Error Domain=NSCocoaErrorDomain Code=516 "A file with the same name already exists."
Fetched https://github.com/scottrhoyt/SwiftyTextTable.git (3.07s)
Fetched https://github.com/jpsim/SourceKitten.git (3.07s)
Fetching https://github.com/apple/swift-syntax.git
Fetching https://github.com/jpsim/Yams.git
Fetched https://github.com/apple/swift-argument-parser.git (3.18s)
Fetching https://github.com/JohnSundell/CollectionConcurrencyKit.git
Fetched https://github.com/JohnSundell/CollectionConcurrencyKit.git (1.05s)
Fetching https://github.com/drmohundro/SWXMLHash.git
Fetched https://github.com/jpsim/Yams.git (3.71s)
Fetching https://github.com/krzyzanowskim/CryptoSwift.git
Fetched https://github.com/drmohundro/SWXMLHash.git (2.69s)
Fetched https://github.com/krzyzanowskim/CryptoSwift.git (4.07s)
Fetched https://github.com/apple/swift-syntax.git (8.86s)
Computing version for https://github.com/krzyzanowskim/CryptoSwift.git
Computed https://github.com/krzyzanowskim/CryptoSwift.git at 1.6.0 (1.28s)
Computing version for https://github.com/JohnSundell/CollectionConcurrencyKit.git
Computed https://github.com/JohnSundell/CollectionConcurrencyKit.git at 0.2.0 (1.21s)
Computing version for https://github.com/scottrhoyt/SwiftyTextTable.git
Computed https://github.com/scottrhoyt/SwiftyTextTable.git at 0.9.0 (6.23s)
Computing version for https://github.com/jpsim/Yams.git
Computed https://github.com/jpsim/Yams.git at 5.0.5 (2.51s)
Computing version for https://github.com/jpsim/SourceKitten.git
Computed https://github.com/jpsim/SourceKitten.git at 0.34.1 (1.77s)
Computing version for https://github.com/apple/swift-syntax.git
Computed https://github.com/apple/swift-syntax.git at 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-03-17-a (1.61s)
Computing version for https://github.com/apple/swift-argument-parser.git
Computed https://github.com/apple/swift-argument-parser.git at 1.2.1 (1.36s)
Computing version for https://github.com/drmohundro/SWXMLHash.git
Computed https://github.com/drmohundro/SWXMLHash.git at 7.0.1 (1.23s)
Creating working copy for https://github.com/JohnSundell/CollectionConcurrencyKit.git
Working copy of https://github.com/JohnSundell/CollectionConcurrencyKit.git resolved at 0.2.0
Creating working copy for https://github.com/drmohundro/SWXMLHash.git
Working copy of https://github.com/drmohundro/SWXMLHash.git resolved at 7.0.1
Creating working copy for https://github.com/apple/swift-syntax.git
Working copy of https://github.com/apple/swift-syntax.git resolved at 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-03-17-a
Creating working copy for https://github.com/scottrhoyt/SwiftyTextTable.git
Working copy of https://github.com/scottrhoyt/SwiftyTextTable.git resolved at 0.9.0
Creating working copy for https://github.com/jpsim/SourceKitten.git
Working copy of https://github.com/jpsim/SourceKitten.git resolved at 0.34.1
Creating working copy for https://github.com/jpsim/Yams.git
Working copy of https://github.com/jpsim/Yams.git resolved at 5.0.5
Creating working copy for https://github.com/apple/swift-argument-parser.git
Working copy of https://github.com/apple/swift-argument-parser.git resolved at 1.2.1
Creating working copy for https://github.com/krzyzanowskim/CryptoSwift.git
Working copy of https://github.com/krzyzanowskim/CryptoSwift.git resolved at 1.6.0
Downloading binary artifact https://github.com/realm/SwiftLint/releases/download/0.51.0/SwiftLintBinary-macos.artifactbundle.zip
Downloaded https://github.com/realm/SwiftLint/releases/download/0.51.0/SwiftLintBinary-macos.artifactbundle.zip (2.42s)
[2/2] Compiling plugin SwiftLintPlugin
Environment
- SwiftLint version (latest)?
- Installation method used (Source?
Metadata
Metadata
Assignees
Labels
discussionTopics that cannot be categorized as bugs or enhancements yet. They require further discussions.enhancementIdeas for improvements of existing features and rules.
Activity
SimplyDanny commentedon Apr 3, 2023
Up to now no one seems to be using SwiftLint on Windows. You may try to get it running in a WSL2 environment. Other than that, we'll have to wait for a motivated user to fiddle with this.
roman-bcny commentedon Nov 10, 2025
hey @SimplyDanny, checking if the current Windows state is as described above or if anything changed, and if you're open to taking Windows-specific contributions including a Windows release workflow so that releases include .exe/.msi files.
(if everything works) this would be structured similarly to this SwiftFormat workflow we did recently and generate a statically linked .exe: nicklockwood/SwiftFormat#2265
Hopefully the static linking will soon be converted to the main sdk and shipped in an upcoming swift release https://forums.swift.org/t/upcoming-changes-to-windows-swift-sdks/81313/43
Let us know if you're anticipating any issues with this or have preferences on the structure (eg installers)
cc @compnerd
compnerd commentedon Nov 10, 2025
See #5030
roman-bcny commentedon Nov 10, 2025
ah thanks I only searched issues, should've checked open PRs!
SimplyDanny commentedon Nov 11, 2025
Some time has passed and dependencies progressed in this regard. In fact, with @compnerd's changes in #5030 everything builds, but some test fail on Windows. I guess, it's because the replacement implementations are not fully correct yet.
I'd be happy to support in moving this forward. As a first step, we should rebase and update #5030. Ideally, we could bring it into a state that builds. Even better would be all tests passing in a basic GitHub Actions workflow.
The next and final step would be building release artifacts and their integration into the release workflows.
What do you guys think? I appreciate your help!
roman-bcny commentedon Nov 11, 2025
@SimplyDanny ha nice, so we shouldn't need the SourceKitten patch any more? (unless that's the reason tests are failing I suppose...) I'll have a look to see if I can build and figure out the test failures, but if there's not too many of those it's already very encouraging!
compnerd commentedon Nov 12, 2025
I've rebased the original PR; seems that SourceKitten is still referenced?
compnerd commentedon Nov 12, 2025
import XCTest
class MyTests: XCTestCase {
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
func testExample() {}
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
}
import XCTest
open class BestTestCase: XCTestCase {}
class MyTests: BestTestCase {
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
func testExample() {}
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
}
/* 👨👩👧👦👨👩👧👦👨👩👧👦 */
import XCTest
class MyTests: XCTestCase {
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
func testExample() {}
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
}
/* 👨👩👧👦👨👩👧👦👨👩👧👦 */
import XCTest
open class BestTestCase: XCTestCase {}
class MyTests: BestTestCase {
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
func testExample() {}
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
}
#!/usr/bin/env swift
import XCTest
class MyTests: XCTestCase {
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
func testExample() {}
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
}
#!/usr/bin/env swift
import XCTest
open class BestTestCase: XCTestCase {}
class MyTests: BestTestCase {
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
func testExample() {}
^ error: Unused Declaration Violation: Declarations should be referenced at least once within all files linted (unused_declaration)
}
References to SwiftUI and CF types are not really going to be portable.
SimplyDanny commentedon Nov 12, 2025
That's what I meant: It builds and test run, yet some tests fail. The
swiftlintbinary can also be built and it runs, but fails to find/read the configuration file.What both tests and running the binary show is that that there are issues in all interactions with the file system. That's mainly all the ones in
FileSystemAccessTestsandIntegrationTests. There are also other failures related to SourceKit usage indeed. I'd need to analyze this more detailed to see whether it's "only" a SourceKit(ten) problem.Maybe we could focus on file system access first, so that related tests pass and the binary itself can be used for non-SourceKit rules? SourceKit usage can be disabled by setting
SWIFTLINT_DISABLE_SOURCEKITas an environment variable.We also provide a static Linux binary now that has SourceKit strictly disabled. This could also be an option for Windows if getting this to work was too much of an effort. There is only a handful of SourceKit-dependent rules left (ones that haven't been migrated to SwiftSyntax). The static binary can anyway not load libraries dynamically at runtime, or can it in the Windows case?
SimplyDanny commentedon Nov 12, 2025
Adding
* text=auto eol=lfto the.gitattributesfile and ensuring that all locally checked out files use\nline endings fixes some tests. I think this is a valid prerequisite for now as SwiftLint just hasn't been build with\r\nin mind.roman-bcny commentedon Nov 12, 2025
@SimplyDanny I checked with @compnerd and I'll be adding commits to the PR to fix the remaining issues. If we can merge that PR without figuring everything out so that we can resolve remaining issues in follow-ups, even better - but if that's not how you'd like to see it that's fair.
Going with
SWIFTLINT_DISABLE_SOURCEKITsounds good, at least as a starting point. Hopefully we can move the rest of what we need to SwiftSyntax or stop using that. One less dependency to worry about sounds nice :)compnerd commentedon Nov 12, 2025
Wait, is the dependency on SourceKit or SourceKitten? SourceKit is available on Windows, it is SourceKitten that is not.
SimplyDanny commentedon Nov 12, 2025
The dependency is on SourceKit through SourceKitten, since SourceKitten being a wrapper around SourceKit.
Surprisingly, I was able to run all but 2
GeneratedTestson your branch successfully. But there are definitely more than 2 rules still relying on SourceKit(ten). So this already seems to work for the most part even without fixes in SourceKitten.compnerd commentedon Nov 12, 2025
That isn't too surprising - I had SwiftLint mostly passing tests when I originally did the port. The few last issues are new paths that are not handling the file system representation correctly I believe. That shouldn't be too difficult to repair. IMO, it might be better to merge these changes and then do separate work to get the test suite to pass.
roman-bcny commentedon Nov 13, 2025
I'm trying to compare
swift testruns on Mac vs Windows, and it appears that Windows only runs ConfigurationTests and BaselineTests suites. I see close to 100 suites on Mac as well as many GeneratedTests which don't show up on Windows. This is probably not expected?roman-bcny commentedon Nov 13, 2025
However,
swift test listlist 1024 tests, identically on Mac and Windows (modulo ordering and crlf)roman-bcny commentedon Nov 14, 2025
Previous comments were on arm64, where things might be broken...
Re-checked on x64 and it seems to be running more tests, but still interrupted by
testValidRemoteChildConfigand further tests don't run (the next one was supposed to betestValidRemoteParentConfigbut the harness exited)@SimplyDanny if you're seeing this as well that might explain why you're seeing less failures than expected. In my tests GeneratedTests don't run at all, for example.
SimplyDanny commentedon Nov 14, 2025
I ran every test target separately to reduce the risk of these interference failures. GeneratedTests alone runs with a few tests being marked as "skipped", which seems to be a glitch in VS Code; the console reports them as "passed". I tested on x86_64 only.
I'm okay with merging the PR as is once the linting issues are resolved. At least, it builds on Windows with that, which is a first important step. A bunch of follow-up fixes will be required to get it fully working. We may track them in sub-issues.
roman-bcny commentedon Nov 20, 2025
@compnerd it seems I'm unable to push to the PR - possibly due to missing checkbox "Allow edits by maintainers" on the PR (but I have no idea how this works)
But here's the change that gets rid of the GeneratedTests failures for me (moving a few cases to be macOS specific due to objc, XCTest that requires platform sdk setup for compilation, CoreFoundation):
roman-bcny@6644344
Tested on 6.2.1 toolchain with
compnerd commentedon Nov 21, 2025
@roman-bcny I don't think that is the right way to address the issues. I have a different approach that accomplishes the same result (I have all the generated tests passing as well). However, I want to split up with the work to address the test failures from the actual port. If everyone else would like to merge it together, I can put it on top of the existing windows PR.
Given that @SimplyDanny had mentioned that he is fine with splitting up the work, I've addressed the concern holding up the change, and I think that we should be able to move forward with getting that merged.
roman-bcny commentedon Nov 21, 2025
#5030 merged - woohoo!
@compnerd fair enough, I just thought those failures were one of the blockers but I now see I misunderstood.
@SimplyDanny looking forward to further steps as described in #5030 (review), please loop me in
SimplyDanny commentedon Nov 21, 2025
With #5030 merged, SwiftLint compiles successfully on Windows. That's an important first step. More tasks will be tracked in the parent issue of this ticket.