SolaWing / xcode-build-server

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

Can't get cross file jump to definition works #38

Closed lelonco closed 9 months ago

lelonco commented 9 months ago

I'm using VSCode with an installed Swift extension. I'm using this build command to build the app rm -r .bundle*; xcodebuild -project *.xcodeproj -sdk ${command:ios-debug.targetSdk} -destination 'generic/platform=iOS Simulator' -configuration Debug -resultBundlePath .bundle build | xcpretty && exit ${PIPESTATUS[0]} | xcode-build-server parse -a | pbpaste | xcode-build-server parse -a It is built correctly. Xcode version: 15.2 Server path in Swift extension: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp

Here is my log file from sourcekit lsp: log.txt

In this issue, I found that message from you. But I can't figure out how to set other sdk, mb I shouldn't change it 😅 https://github.com/SolaWing/xcode-build-server/issues/32

from the log seems xcode-builld-server cannot read correct flags, and return the default flags: ["/Users/beng/Downloads/NewTest/NewTest/NewTest/ViewController.swift", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/"], which is not compatible with your Xcode-15.2.0.app version.

buildServer.json looks like that Screenshot 2024-02-16 at 01 21 11

SolaWing commented 9 months ago

xcode-build-server parse should use raw xcode build log, this can be get by xcodebuild build command or export from Xcode Log UI. It can't work after filtered by xcpretty. also notice increment build from xcodebuild, not contains all logs. so first parse from xcodebuild should be a clean build.(Xcode Log UI has all logs, so don't have to clean build)

lelonco commented 9 months ago

Thank you for fast response. I removed xcpretty, and now my command is: rm -r .compile*; rm -r .bundle*; xcodebuild -project *.xcodeproj -sdk ${command:ios-debug.targetSdk} -destination 'generic/platform=iOS Simulator' -configuration Debug -resultBundlePath .bundle build | pbpaste | xcode-build-server parse -a But now I can't get the build log. I'm also trying to use exit ${PIPESTATUS[0]} from xcpretty command, but it didn't help

Screenshot 2024-02-16 at 12 04 21

also notice increment build from xcodebuild, not contains all logs. so first parse from xcodebuild should be a clean build.(Xcode Log UI has all logs, so don't have to clean build)

I make a clean build folder using Xcode. But it still not working

I also find that .compile file is empty Content of file: Screenshot 2024-02-16 at 12 14 58

SolaWing commented 9 months ago

pbpaste is used if you manual copy log from terminal or copy. if you use xcodebuild, the command should be: xcodebuild <param> clean build | xcode-build-server parse -a. xcode build server only accept output from xcodebuild. if you run xcodebuild without xcode-build-server, you will see swiftc compile command in the output. that is the flags xcode-build-server get from

lelonco commented 9 months ago

Thank you for your help. It works now If I want to see the xcpretty log I need to specify xclog file path?

SolaWing commented 9 months ago

if you want to see xcpretty output,you should reuse your log output. you tee your log output to a file, then reuse the file for parse. eg `xcodebuild clean build | tee /tmp/xcodebuild.log | xcpretty; xcode-build-server parse -a /tmp/xcodebuild.log

lelonco commented 9 months ago

should I make a clean build every time?

SolaWing commented 9 months ago

should I make a clean build every time?

no,only first time. xcode-build-server parse -a will ensure merge newest logs with old logs

lelonco commented 9 months ago

thank you for detailed response