nicklockwood / SwiftFormat

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

Continuing to get Xcode crash on `CMD+S` save with SwiftFormat #1897

Open WestFlow127 opened 3 weeks ago

WestFlow127 commented 3 weeks ago

I have recently upgraded to macOS Sonoma/Xcode 16, and continue to get an Xcode crash when I save my swift file. It does not happen every time, but about ~10% of file-saves do this. My current SwiftFormat build is 0.54.5.

Would it help if I attached my Xcode crash report here? I thoroughly like using SwiftFormat, but the Xcode crashes can cause me to lose changes. Thanks

nicklockwood commented 3 weeks ago

I'm a bit confused. SwiftFormat does not have a mechanism for formatting on save in Xcode - is that something you have implemented yourself?

And if not, what leads you to believe that SwiftFormat is the cause of the crashes?

WestFlow127 commented 3 weeks ago

@nicklockwood yes, I've added a keyboard shortcut demonstrated in this tutorial here. The indication of something SwiftFormat related with regards to the crash is the crash happens immediately after the shortcut CMD+S is executed and otherwise does not occur.

WestFlow127 commented 3 weeks ago

In theory, it may be because Xcode is trying to save the file during the formatting process (writing to the swift file) which bugs out Xcode to abort.