Open yaroslavyaroslav opened 1 year ago
Tracked in Apple’s issue tracker as rdar://46844528
You can trick it.
You need a dummy Package.swift
file in your root. Then you can copy the symbols from your Xcodebuild to the .build folder that SPM uses. I use this technique in Emacs to get full support for symbols in Emacs.
You also need to send sdk
and target
to the LSP server.
It's a bit tricky, but it works great for me.
https://github.com/konrad1977/emacs/blob/main/localpackages/swift-additions.el I don't know which editor you are using. But if you are using Emacs reach out - I would be happy to help you.
@konrad1977 to you for sharing that hack! Didn't knew about that. Could you please point me out to the line in your plug-in that passes target to the lsp server?
Ps: unfortunately I'm not a emacs under, but I guess I would be able to understand the logic behind the code.
-Xswiftc "-sdk" -Xswiftc "xcrun --sdk iphonesimulator --show-sdk-path" -Xswiftc "-target" -Xswiftc "arm_64-apple-ios16.2-simulator"
This thread is a good starting point: https://forums.swift.org/t/how-to-use-sourcekit-lsp-with-ios-projects/28273
@konrad1977 Thank you so much for that link. There I was found xcode-build-server utility. Though it's manual it fits my needs.
I would not close this issue though, since I do not consider that utility as a comprehensive solution.
Hey, @konrad1977 sorry to bother you after such a long time.
I've tried just now your approach to make sourcekit-lsp
working, and it works great at my side. But there's just one issue I've faced: it's unable to fetch data from any dependency package that I have.
I've looked at a glance into your command that is copying xcodebuild
derived data into a SPM .build
folder and as far as I can tell there's no dependencies handling here rsync -ua --include='*/' --delete --include='*.swiftmodule' --exclude '*'
.
Do I missing something or is it made such by purpose?
Worth to say I'm having no clue where these dependencies are stored within derived data, so for me this is research yet to be done.
UPD: Giving a quick look to the DerivedData
folder of a xcodebuild
project and the .build
folder of a SPM project and I've noticed that pretty much the same files that is stored within SomeYourPackageName.build
are stored within Intermediates.noindex
folder right next to Products
folder that is your pointing to at the emacs config that you've provided earlier.
I've read the readme about Indexing while building technique, so I've got the point. And also I'm aware that
swift
itself has a limited support for Xcode projects by purpose.Anyway, is there a way to index [use Xcode index somehow] the code by
xcodebuild
, to make LSP work with it at least in a less limited way?UPD: here's the best solution that I was able to find: xcode-build-server it's still quite limited so far, but yet it's reliable and straightforward in its usage.