-
Notifications
You must be signed in to change notification settings - Fork 33
Fix missing iOS flags for SwiftPM packages (for ~/Library/Developer/Xcode/*/DerivedData/* files related to project) #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
If a checkout lacks a local `.compile-*`, _InferFlagsForSwift_ now re-searches from cwd. This picks up the workspace-level `.compile` written for SourcePackages and stops library files from falling back to macOS SDK.
Normally, xcode-build-server will find and use the corresponding compile file through the configuration in On the other hand, SourcePackages/checkouts/* is outside the current directory. Most editors will generate a new root directory. There is no buildServer.json in this root directory, and sourcekit-lsp will not get flags through BSP. So I am curious about your Integrated environment and configuration. I will try to reproduce the usage scenario and see if there is a better solution. |
I’m working on this project: https://github.com/mishabunte/unstoppable-wallet-ios
Fix: I added a fallback in InferFlagsForSwift and findSwiftModuleRoot that checks the current working directory if no .compile file is found. With this change, I can navigate both the project’s source code and the dependency sources. |
see https://github.com/SolaWing/xcode-build-server/blob/5d1012ce5d008c77cec8be963d4c525ddb683635/server.py#L121C1-L121C73 BSP server already pass current compile_file to get flags, if it contains flags for file, there shouldn't enter the infer branch. Except you start another BSP server instance for different root. Did you have any buildServer.json in parent directory of Or Can upload your logs? it can be export to a file by start LSP with environment |
No, I don't have buildServer.json in Xcode/DerivedData. Xcode creates this folder automatically for the third-party libraries My project has buildServer.json. But my project is in my home folder - ~/prj/unstoppable-wallet-ios The fix is propose is very simple: xcode-build-server will use project's buildServer.json for all third-party libraries for the specific project (Xcode puts the source code for the third-party libraries into The easiest way is to use project's buildServer.json for third-party libraries and it works perfect - check the FilesChanged: |
I perform these steps
Please find logs before and after the patch: |
I noticed that Lines 76 to 85 in e541f03
Line 121 in e541f03
.compile information correctly, not by inferring them through fallback unknown files.
If the kind field in your |
Fix: SwiftPM/CocoaPods source files in
SourcePackages/checkouts/* were indexed with MacOSX.sdk because the
upward search never found a .compile-* file.
Change:
findSwiftModuleRoot() accepts an optional start directory.
On a miss, InferFlagsForSwift() retries from os.getcwd() (workspace
root), where the real .compile-* lives.
Result: package sources now receive the correct iOS/iOS-sim flags, so
SourceKit-LSP regains hover and go-to-definition for library code.