SourceKit LSP Plugin support for Xcode?

I wrote a Swift C# SourceKit LSP mod that wraps OmniSharp, hoping to use it to get C# support in Xcode. But I cannot for the life of me see how to get Xcode Or Visual Studio Code to recognize it. Does anyone know or is Xcode still walled garden in this respect?

Yes, Xcode is still limited in this way. It does not support LSPs at all. VSCode supports LSPs but I don't know what you're doing.

First of all, I too, don't know what I'm doing. Making a custom fork of sourcekit-lsp that supports C# seems kind of crazy, it was more just to learn LSP and sourcekit.

For sure, I was under the mistaken impression that Xcode used sourcekit-lsp under the hood for Swift syntax highlighting, and that an Xcode plugin could supply it or it would pick it up automatically from a custom toolchain.

But I guess I'll add a feature request for that.

People will say "why would you ever want to use Xcode for C# development"?

Frankly I just really like Xcode. I like its UI and features best among all the IDEs I've tried. Visual Studio on Windows is hideous. Visual Studio Code and JetBrains stuff are OK, but they lack some key Xcode features that I rely on. (For example, searches you perform in Xcode are tied to the tab you did it on, so if you switch tabs then you can do another search without clearing the prior one.) There are a lot of other reasons aside from that.

Yes, it sounds crazy :) Why not use a ready-made C# language server? I think there should be "the official" one from Microsoft (especially in VS Code), and some 3rd-party options, like this one.

If you use C#, I can guess you are writing apps for Windows. How do you plan to create Windows GUI in Xcode? Do you intend to use the Interface Builder for that?

Back to reality... I think this use of Xcode may constitute a violation of Xcode's license.

I just skimmed the Xcode EULA, it seems to only restrict the use of Apple SDKs to branded Apple devices, and Apple Apps to these as well. So, as long as the output contains no Apple resources, or is only used on Apple devices, you're good. But of course, if you are a commercial developer, have your lawyer read the EULA.

1 Like

My mod just wraps Omnisharp (the official Microsoft one).

1 Like

I'm mainly a Swift dev. I've been donating time on a C# open source project to expand horizons, ]] learn another platform, and because I use the app and wanted help improve it.

But I was getting a bit frustrated with the IDEs on Windows. I'm not a huge fan of VSCode or Visual Studio, JetBrains is the best but lots of things about it annoy me. So I just wanted to use XCode as a code editor, it has features like making a new tab set preserves the search history on the other tab, filtering the sidebar actually filters it and doesn't just search it, great code folding, etc.

And Xcode has syntax highlighting for just about every language—Fortran 90, PHP, Ruby, DTrace—but not C#, which is #10 among languages by percent of code on Github. So I guess it just kinda surprised me they didn't have C# highlighting at least, especially since there seems to be a Swift-on-Windows effort. Seems like if that's gonna go anywhere then someday there will need to be at least a degree of C# interoperability—realizing of course that it's a very different language (programming in it feels to me a lot more like Obj. C in terms of runtime dynamism).

It would be cool someday to see Apple open up SwiftUI to be able to genuinely be adapted to building apps for Apple platforms and also have either them or the open source community be able to build out support for UI on some of these other platforms. I doubt Apple would ever support that officially like MS does with Xamarin, and some of the others, but opening up the thing to open source efforts could be cool. Eh, maybe someday.

For now maybe just a way to add syntax coloring or additional LSP's into Xcode could be cool.

1 Like