nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.92k stars 639 forks source link

Config File: swiftversion #1427

Closed michaeldclifford closed 1 year ago

michaeldclifford commented 1 year ago

Scenario 1 (Swift 5.7.2)

Config File

--swiftversion 5.7.2

--exclude Pods

--self init-only
--patternlet inline
--importgrouping testable-last

--enable \
    blankLineAfterImports, \
    blankLinesBetweenImports, \
    blockComments, \
    isEmpty, \
    sortedSwitchCases, \
    wrapEnumCases

Output

$ swiftformat .

Running SwiftFormat...
Reading config file at `folder/.swiftformat`
 SwiftFormat completed in 1.32s.
 0/788 files formatted, 1 file skipped.

Scenario 2 (Swift 5.8)

Config File

--swiftversion 5.8

--exclude Pods

--self init-only
--patternlet inline
--importgrouping testable-last

--enable \
    blankLineAfterImports, \
    blankLinesBetweenImports, \
    blockComments, \
    isEmpty, \
    sortedSwitchCases, \
    wrapEnumCases

Output

$ swiftformat .

Running SwiftFormat...
Reading config file at `folder/.swiftformat`
 error: Failed to terminate.
 error: Failed to terminate.
 error: Failed to terminate.
 error: Failed to terminate.

It seems like SwiftFormat runs anyway, but just ignoring the config file contents, eg Pods/* is not excluded. There may be something obvious that I'm doing wrong, so please do let me know if so. --swiftversion 5.8.0 produces the errors as well, but --swiftversion 5, --swiftversion 5.6, and --swiftversion 5.7 do not.

nicklockwood commented 1 year ago

@michaeldclifford can you run with --verbose mode and share the file that it got stuck on? It will be the last one logged before the failure to terminate message.

michaeldclifford commented 1 year ago

Although I was able to reproduce this several times, after a machine restart it no longer appears to be an issue. I'm afraid I've no idea what was causing it, as it now works as expected.

Thanks 🙂