nicklockwood/SwiftFormat

Xcode source editor extension not visible in System Preferences - Extensions

rudifa opened this issue · 11 comments

I have used swiftformat successfully since mid-2018, mainly via Editor Extension in Xcode.

However, after installing macOS 10.15 and Xcode 11.1 the Extension menu items (Format Entire File, Format Selected Source) disappeared from the Xcode Editor menu.

I pulled the project from https://github.com/nicklockwood/SwiftFormat.git and ran SwiftFormat for Xcode.app, then looked into System Preferences - Extensions, but I found no trace of Xcode extensions or swiftformat therein.

Next, I built and run the scheme SwiftFormat for Xcode. The app dialog popped up, but again there was no new entry in System Preferences - Extensions.

Am I missing something?
Any advice on how to proceed?
Is there a log file that would indicate the problem?

OK, I found a solution to my problem.

The article Xcode​Kit and Xcode Source Editor Extensions by Zoë Smith, March 25th, 2019, says:

Finally, when multiple copies of Xcode are on the same machine, extensions can stop working completely. In this case, Apple Developer Relations suggests re-registering your main copy of Xcode with Launch Services (it’s easiest to temporarily add lsregister’s location to PATH first):

$ PATH=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support:"$PATH"
$ lsregister -f /Applications/Xcode.app

Indeed, before installing Xcode 11.0, I kept the previous app, renamed to Xcode1030.app.

I ran above commands, and lo, the swiftformat extension is now in seen in Extensions, enabled.
And in Xcode, the Editor - SwiftFormat menu items are at their usual place, together with my shortcut ^s for Format Entire File.

Screenshot 2019-10-28 at 19 58 31

Makes sense, thanks for following up 👍

nice

OK, I found a solution to my problem.

The article Xcode​Kit and Xcode Source Editor Extensions by Zoë Smith, March 25th, 2019, says:

Finally, when multiple copies of Xcode are on the same machine, extensions can stop working completely. In this case, Apple Developer Relations suggests re-registering your main copy of Xcode with Launch Services (it’s easiest to temporarily add lsregister’s location to PATH first):

$ PATH=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support:"$PATH"
$ lsregister -f /Applications/Xcode.app

Indeed, before installing Xcode 11.0, I kept the previous app, renamed to Xcode1030.app.

I ran above commands, and lo, the swiftformat extension is now in seen in Extensions, enabled.
And in Xcode, the Editor - SwiftFormat menu items are at their usual place, together with my shortcut ^s for Format Entire File.

Screenshot 2019-10-28 at 19 58 31

nice,thanks

klaas commented

Great tipp! This should be included in the FAQ / Known Issues section!

Every once in a while the "SwiftFormat" menu gets missing in my Xcode installation and this helps!

OK, I found a solution to my problem.

The article Xcode​Kit and Xcode Source Editor Extensions by Zoë Smith, March 25th, 2019, says:

Thank you for posting this.

Its worked @limuyang2 🎉

$ PATH=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support:"$PATH"
$ lsregister -f /Applications/Xcode.app

not working for me, unfortunately.

I noticed with Xcode 14 that once I upgraded using the brew cask method I could not get it to re-appear in Xcode 14. However, if I downloaded and installed the application from the releases tab it reappeared.

May be of use (at least to myself when I come looking for this again in a year or so's time :-) )

In my case is that, once you done with brew install, go to "Applications > SwiftFormat for Xcode" and simply double click to open it

Thank you for your guidance, it solved the issue of the Xcode 15 editor menu not displaying for me.

I noticed with Xcode 14 that once I upgraded using the brew cask method I could not get it to re-appear in Xcode 14. However, if I downloaded and installed the application from the releases tab it reappeared.

May be of use (at least to myself when I come looking for this again in a year or so's time :-) )

Thank you. This worked for me too.

Xcode 15.2
Sonoma 14.3
SwiftFormat 0.53.1 from GitHub releases

Opened /Applications/SwiftFormat for Xcode.app and then enabled extension in System Settings -> Privacy & Security -> Others, Extensions -> Xcode Source Editor -> ☑️ SwiftFormat