SolaWing / xcode-build-server

a build server protocol implementation for integrate xcode with sourcekit-lsp
MIT License
283 stars 16 forks source link

Sample project? #23

Closed konrad1977 closed 7 months ago

konrad1977 commented 7 months ago

I cannot get it working. Can you setup a sample project to get it working? I am using Emacs (still need an xcworkspace though but I am building using xcodebuild with parsed information from xcworkspace/xcodeproj), I need to pass any argument to source kit-lsp or (target|sdk)?.

I can get the basics of swiftui and foundation completions but not from my own code. Earlier I used the trick with a package.swift in the root to fool sourcekit-lsp but it doesn't seem to work with xcode15.

konrad1977 commented 7 months ago

I got it working after I compiled using xcodebuild ... | xcode-build-server parse

SolaWing commented 7 months ago

I want to know what steps you have taken and what difficulties you have encountered, and it doesn't work in the end. This may help me improve the usage guide.

All this project requires is:

  1. build workspace though xcode or xcodebuild
  2. Use the xcode-build-server command to generate buildServer.json (needs to be in the lsp-root directory). That is, if you use the Xcode GUI to build, you can use the same workspace and scheme as parameters to call the xcode-build-server config to monitor the build output using Xcode. Or, as you said above, provide build logs and call xcode-build-server parse to set them manually

You don't need to do any additional setup for soucekit-lsp. As long as there is a buildServer.json file in lsp-root, sourcekit-lsp will call the command provided here to get the compile flags

konrad1977 commented 7 months ago

I got it working, but do you need to clean the build every time before you updating the.compile commands?

When you build using xcodebuild it will create a folder called XCBuildData. Would it be possible to regenerate the .compile commands from any of the files from its output instead of parsing the data directly from xcodebuild output?

SolaWing commented 7 months ago

You could use xcode-build-server parse -a to only overwrite new item, keep old item untouched. if you build use xcode app, it can choose all log, and export to a file.

For generate command from any of the files, can you enlighten me how to get the build flags?

konrad1977 commented 7 months ago

I am planning to do this automatically using Emacs. So I always have an up to date version of .compile commands.

konrad1977 commented 7 months ago

So If I understand you correctly if you pass xcodebuild [...] | xcode-build-server parse -a it will apply the changes needed to update lsp-server if you changed any file?

SolaWing commented 7 months ago

So If I understand you correctly if you pass xcodebuild [...] | xcode-build-server parse -a it will apply the changes needed to update lsp-server if you changed any file?

yes.