Closed bengidev closed 3 months ago
@bengidev Your build_root_dir
seems incorrect.. xcode-build-server expect to read xcode build log from <build_root_dir>/Logs/Build/
dir. this dir normally default to ~/Library/Developer/Xcode/DerivedData/XXX-hash
can you show me your xcodebuild -showBuildSettings -scheme Orbinews -workspace XXX | fgrep BUILD_DIR
result?
seems you change the default build dir, and the build_dir has space in path, so extract build_root failed..
I push a fix to allow space in BUILD_DIR, you can check if your LSP works?
@bengidev did it help?
I've try this way, don't hesitate to correct me.
I pull the latest version from this repo
This is my lspconfig
for NeoVim with Lazy
I generate buildServer.json
using this command xcode-build-server config scheme Tester -project *.xcodeproj
This is my buildServer.json
result:
This is the LspConfig
result:
This is the LspLog
result:
There's no code completions/suggestions appears when i type impo
in the ViewController.swift
file
I'm sorry for my late responses, mate 🍻
@bengidev this time your build_root seems correct.
I see you use -project(not workspace) as config, and your xcode is custom Xcode-15.2.app, so you should check you use same project and same xcode version as xcode-build-server config. after you build, you should see a newer log in your configed build root, see ls -al ~/Library/Developer/Xcode/DerivedData/Tester-*/Logs/Build
, xcode-build-server get flags from it.
if you log generate correctly, you can check detail logs by export envirment: SOURCEKIT_LOGGING=3
, you export in your terminal if you use terminal vim, or set in your vim's environment before lsp start.
you can also check if you create a newer demo project, if it works?
I'm sorry, i don't get what you suggestso you should check you use same project and same xcode version as xcode-build-server config
. Can you explain more simpler to me?
And where am i supposed to put this SOURCEKIT_LOGGING=3
?
ls -al ~/Library/Developer/Xcode/DerivedData/Tester-*/Logs/Build
let $SOURCEKIT_LOGGING="3"
I try to run your number 1 suggestions, but i still don't understand your number 2 suggestions, sorry.
I try to create new project with name NewTest
:
This is xcode-build-server config -scheme NewTest -project *.xcodeproj
result:
This is ls -al ~/Library/Developer/Xcode/DerivedData/NewTest-*/Logs/Build
result:
seems you have multiple NewTest log output, and newest is build at 14:53. is this the NewTest-fdomdvhi*
dir same as build_root? did this new project works?
for set environment, you can exe script at begin of your nviminit, use:
vim.env.SOURCEKIT_LOGGING="3"
in lua,
or let $SOURCEKIT_LOGGING="3"
in vimscript
This is when i try to set the environment using Lua
:
This is when i try to re-create xcode-build-server config -scheme NewTest -project *.xcodeproj
:
This is when i try to open NewTest-domdvhi*
:
This is the LspLog
when i try to type impo
in ViewController.swift
file:
Can you upload the LspLog as file? screenshot seems be truncated
This is the LspLog.txt
:
LspLog.txt
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.
when you run build, you can check if your build updating logs in ls -al /Users/beng/Library/Developer/Xcode/DerivedData/NewTest-domdvhivimfpzmckkmtgkilvyjxk/Logs/Build
dir. you also can view your build log output, see if it has same base dir as /Users/beng/Library/Developer/Xcode/DerivedData/NewTest-domdvhivimfpzmckkmtgkilvyjxk/
(by the way, if you has the full xcode log, you can copy it and run pbpaste | xcode-build-server parse
at you lsp root dir, as Readme Manual Parse Xcodebuild log shows, though this way will not auto update new flags when you build)
if the build dir correct and the log is updated, you can check the log-file contains the correct logs (extract it by cmd xcode-build-server debug print-xclog <path_to.xcactivitylog>
, I just provide it in newest version)
the log should contains a cmd like /Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name <YourModule>
. if this case, you completion should work.
or if log correct, but xcode-build-server can't analyze the log(by cmd xcode-build-server parse -l <Path-to.xcactivitylog> -o -
), you can upload the log file for me to debug it.
I try to run this command xcodebuild -project *.xcodeproj -scheme NewTest -configuration Debug build | xcode-build-server parse
pbpaste | xcode-build-server parse
, and this is the result:
I try to check if your build updating logs in ls /Users/beng/Library/Developer/Xcode/DerivedData/NewTest-domdvhivimfpzmckkmtgkilvyjxk/Logs/Build
:
And i try to view the build log output, and this is the result:
I try to run this command pbpaste | xcode-build-server parse
:
I try to run this command xcode-build-server debug print-xclog
:
And for this command, it seems not right because error happens when i run this xcode-build-server parse -l <Path-to.xcactivitylog> -o -
your build failed without any module flags output?
For your lsp to works, you need to:
/Users/beng/Library/Developer/Xcode/DerivedData/NewTest-domdvhivimfpzmckkmtgkilvyjxk/
ls -al /Users/beng/Library/Developer/Xcode/DerivedData/NewTest-domdvhivimfpzmckkmtgkilvyjxk/Logs/Build
, LogStoreManifest.plist and a newer xcactivitylog is updated./tmp/BuildXXX.log
), and then run cmd xcode-build-server parse </tmp/BuildXXX.log>
. this should also works.I don't know if this works as we expected, but i've try to create new iOS App called Space News, and i've build and run previously in XCode, and when i generate buildServer.json
, and then i try to run in NeoVim again, it seems to works. Like i try to type import fo
and then code completions/suggestions shows up with Foundation
and known as Module
, not Text
again. You can see my screenshoots down below:
I generate the buildServer.json
:
I try to check the build product root:
I try to check Logs/Build
:
And when i try to type import fo
inside working directories:
And this is when i try to type import ui
which is correctly shows the code completions/suggestions as expected:
But when i try to import XCT
, there's no code completions/suggestions shows up:
You also can check my Logs directories here
Maybe try also creating first a project that doesn't contain white spaces in path to make sure that it is not causing any additional problems. And try building the project for tests from Xcode first.
Finally you compile via xcode and it works successfully. for XCTest file to work, you need to build or run test, with the same scheme to generate index and flags.
if you use same scheme to run app and test, like scheme page shows, you just need to run test by Product->Test(hotkey: <Cmd-U>
):
if you test target is in a different schema, you should ensure you config xcode-build-server with same schema and then build test.
for vim plugin works and how to bind vim build to xcode-build-server, you can ask @wojciech-kulik for advice
I try available suggestions, and this is what i get.
I try to run the default test when i create the project:
I try to re-generate buildServer.json
:
I try to re-open NeoVim and try to import xct
and code completions/suggestions shows up:
I try to import inje
and code completions/suggestions shows up:
I try to use Inject
in code, and code completions/suggestions shows up:
I try to use gd
when the cursor above Inject
as for Goto Definition in NeoVim:
And i think finally it works really perfect. Should i close the issue?
Congratulations! If you has no more questions, feel free to close the issue
I think this works very perfect, and i've try to maximize the potentials to see great articles from @wojciech-kulik again.
Thank you very much, for all of you. Keep your great works, and enjoy your life, mate 🍻
I have been experimenting with the Xcode-Build-Server
project using Helix editor and have noticed an interesting behavior regarding LSP suggestions. When creating Xcode projects (Xcode 15.2 (15C500b), Ventura 13.6.1) with the 'create git repo on my mac' option selected, LSP suggestions work perfectly. However, if I disable this option and create the project without a git repository, LSP suggestions do not work. I have verified that all paths are correct and have tested with other projects, but the behavior persists. Interestingly, if I create a project with git disabled and then create a repo with git init, LSP suggestions start working.
I thought this information might be helpful to others who are using the Xcode-Build-Server project and experiencing similar issues.
@ghashy seems this relative how your editor recognize lsp root. git dir normally recognized as lsp root. you should confirm the build server dir is your lsp root dir. this should confirm by lsp logs
@ghashy it's a matter of setting a proper search for your LSP. Here is what I'm doing in my nvim-lspconfig config:
lspconfig["sourcekit"].setup({
capabilities = capabilities,
on_attach = on_attach,
cmd = {
vim.trim(vim.fn.system("xcrun -f sourcekit-lsp")),
},
root_dir = function(filename, _)
local util = require("lspconfig.util")
return util.root_pattern("buildServer.json")(filename)
or util.root_pattern("*.xcodeproj", "*.xcworkspace")(filename)
or util.find_git_ancestor(filename)
or util.root_pattern("Package.swift")(filename)
end,
})
If you run :LspInfo
you can check if the root is properly set.
Hello, i haven't code completions/suggestions while my LSP is successfully activate and i've generate
buildServer.json
in the root of my working directories. Here are some screenshoots for my problem:I want to integrate
SourceKit-LSP
with my NeoVim, and here are my configurations:Here are my cloned
xcode-build-server
repos:Here are my generated
buildServer.json
Here are my working directories
Here are my
LspLog
when i open my Swift file:I try to type
import
and Lsp doesn't give anything about suggestions/completions:So, that's my report for you. I hope i can develop iOS app outside XCode environment. Thank you very much for your great work, mate 🍻