Configuration problem
wojciech-kulik opened this issue ยท 21 comments
I'm using macOS 13.3.1, M1 Pro, Xcode 14.3, lazyvim and I'm unable to make this plugin work.
I tested it on 3 projects and on all of them I get the same error. All those projects are using xcodegen for project generation.
So I installed the plugin like that:
Then I open nvim in the root folder of my project, where project.yml
is located, I open some swift file like AppDelegate.swift
and I use <leader>b
mapping then I always get:
I tried to follow debug steps but there are no logs.
Hello @wojciech-kulik Thanks for reporting. Sorry for your troubles.
It's seems an issue with telescope integration, perhaps the project info isn't correctly stored.
- What version of neovim and the commit of?
- when you open neovim in the project root directory, do you get confirmation that that xbase is connected?
- Is there a xbase process running? You mentioned that no logs found, try to look inti tmp folder
- what's the output of
require'xbase.server'.roots
- what's the output of
require("xbase.state")
Thank you for the quick answer! :)
What version of neovim and the commit of?
NVIM v0.8.3
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Ventura-arm64.local
when you open neovim in the project root directory, do you get confirmation that that xbase is connected?
Is there a xbase process running? You mentioned that no logs found, try to look inti tmp folder
How can I check it? I run this from nvim and I don't see any xbase process:
what's the output of require'xbase.server'.roots
what's the output of require("xbase.state")
I'm sorry, but I'm a new nvim user, where should I put it to see?
How can I check it? I run this from nvim and I don't see any xbase process:
Hmmm it's seems is not running. Try to run it manual, You can find the binary in ~/.local/share/xbase
, if not found, perhaps make install failed
what's the output of require'xbase.server'.roots
what's the output of require("xbase.state")
I'm sorry, but I'm a new nvim user, where should I put it to see?
That's okay, one possible way is to run it in the command line of neovim, for example, lua print(vim.inspect(require("xbase.state"))
xbase.state
returns:
{
project_info = {}
}
require'xbase.server'.roots
returns {}
I don't have this folder ~/.local/share/xbase
, but I have: ~/.local/share/nvim/lazy/xbase/
. So I guess the source code is downloaded but the installation failed?
what should I run from here?
I don't know if it makes sense but I tried to run make install
in this folder and I got:
Ok, I managed to fix this problem. It turned out that I needed cargo, so one extra step was missing - to install:
curl https://sh.rustup.rs -sSf | sh
Then I ran make install
and restarted nvim. Now the xbase
process is running but the error is the same :D
However, now I can see logs, so I will try to investigate what's the problem and I will let you know. Thanks for your patience!
Ok, so I see some problems. My guess is that it won't work with CocoaPods? It looks like it uses only xcodeproj
, am I right?
But I tried with a sample project that uses only xcodeproj
. Although it prints some errors, it looks like the build works and I was able to run it.
Actually, you can try this project on your own:
https://github.com/wojciech-kulik/SwiftUI-Redux-Demo
The main problem that I have with iOS development in nvim is that the code completion doesn't work as expected and navigation to implementation/definition/references doesn't work. Is it possible to do something about that? As far as I read, it is a problem that the LSP doesn't understand the project structure?
@wojciech-kulik Thanks so much for debugging, reaching to the root of it, and providing a repo I can use to debug further.
I will try today use the repo to debug it further and make it work.
@wojciech-kulik I just ran the https://github.com/wojciech-kulik/SwiftUI-Redux-Demo on my environment.
- Project doesn't compile successfully. Even though it says it did and
.compile
was created with empty array. - Trying to build the project using the picker result in build failed.
- The errors you mentioned after first open at decode function is indeed a bug.
I'm guessing permission issues, with some parsing issues. I will build in debug and run the build command manually to see whats wrong exactly. More later
My Environment
Machine
sw_vers
Output
ProductName: macOS
ProductVersion: 13.0.1
BuildVersion: 22A400
Xcode
system_profiler SPDeveloperToolsDataType
Output
Developer:
Developer Tools:
Version: 14.3 (14E222b)
Location: /Applications/Xcode.app
Applications:
Xcode: 14.3 (21812)
Instruments: 14.3 (64559.163)
SDKs:
DriverKit:
22.4:
iOS:
16.4: (20E238)
iOS Simulator:
16.4: (20E238)
macOS:
13.3: (22E245)
tvOS:
16.4: (20L489)
tvOS Simulator:
16.4: (20L489)
watchOS:
9.4: (20T248)
watchOS Simulator:
9.4: (20T248)
Additional SDKs:
iOS:
Asset Runtime SDK for macOS hosts targeting iOS 16.4: 16.4
tvOS:
Asset Runtime SDK for macOS hosts targeting tvOS 16.4: 16.4
watchOS:
Asset Runtime SDK for macOS hosts targeting watchOS 9.4: 9.4
Neovim
nvim --version
Output
NVIM v0.9.0-dev
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by _nixbld6
Features: +acl +iconv +tui
Debugging
- After opening neovim at project root,
ps aux | grep "xbase/xbase"
returns two results (on for grep and xbase process. - After opening neovim at project root, I see project have successfully compiled and
buildServer.json
and.compile
was created. - Whenever I open neovim at project root, you see that the project is registered.
XBase Logs
tail -f /tmp/xbase.log
Output
INFO SERVER STARTED
INFO Client{fd=13}: Connected
INFO Runtime{name="SwiftUI-Redux-Demo"}: [Initializing] ------------------------
INFO Broadcaster{name="SwiftUI-Redux-Demo"}: Created
INFO Runtime{name="SwiftUI-Redux-Demo"}: targets: {"ReduxDemo": TargetInfo { platform: "iOS", configurations: ["Debug", "Release"] }}
INFO Broadcaster{name="SwiftUI-Redux-Demo"}: Connected [50590]
INFO Runtime{name="ReduxDemo"}: Creating "/tmp/SwiftUI-Redux-Demo/buildServer.json"
INFO Runtime{name="ReduxDemo"}: Connected [50590]
INFO FSWatcher{name="ReduxDemo"}: Watching
INFO Runtime{name="ReduxDemo"}: [Initialized] -------------------------
XBase build server logs
tail -f /tmp/xbase-build-server.log
Output (after navigating to a file. In that case Store.swift)
INFO xbase_sourcekit_helper: Started
INFO xbase_sourcekit_helper: Initialized
DEBUG xbase_sourcekit_helper: [Store.swift] Querying compile_db
ERROR xbase_sourcekit_helper: Missing compile arguments for "/tmp/SwiftUI-Redux-Demo/ReduxDemo/App/Store.swift"
Neovim State
print(vim.inspect(require('xbase.state')))
Output (after the project as registred successfully)
{
project_info = {
["/tmp/SwiftUI-Redux-Demo"] = {
targets = {
ReduxDemo = {
configurations = { "Debug", "Release" },
platform = "iOS"
}
},
watchlist = {}
}
},
runners = {
iOS = { {
id = "3E959A4F-AA76-4A29-A898-77112BBDD54F",
name = "iPhone 14 Plus"
}, {
id = "248851A9-D935-4149-993B-62710075AFCD",
name = "iPhone 14 Pro Max"
}, {
id = "AECABAC4-8498-4A82-8026-4F98775AA892",
name = "iPhone 14 Pro"
}, {
id = "88F1DFDB-9195-4DB1-83FE-1CA3AF461104",
name = "iPad Air (5th generation)"
}, {
id = "709AC6C8-99EA-4AD4-9C22-36871639DC97",
name = "iPhone SE (3rd generation)"
}, {
id = "DD1ACCE1-65BD-4489-808D-9E41557EB3F3",
name = "iPad (10th generation)"
}, {
id = "4312DA7A-0E44-4C04-B541-70D454BFE0ED",
name = "iPhone 14"
}, {
id = "7394CCA8-A938-4824-9A48-6D7F5791561A",
name = "iPad mini (6th generation)"
}, {
id = "37E587F6-4F8B-4599-9CDC-8E0EAB786020",
name = "iPad Pro (12.9-inch) (6th generation)"
}, {
id = "5CC8B028-7040-46A5-91C4-2E221BA0C500",
name = "iPad Pro (11-inch) (4th generation)"
} },
tvOS = {},
watchOS = {}
}
}
Neovim Server Roots
print(vim.inspect(require('xbase.server').roots))
Output (after the project as registred successfully)
{
["/tmp/SwiftUI-Redux-Demo"] = true
}
@wojciech-kulik Quick update.
It turned out the project did compile successfully. However, SwiftDriver
wasn't support in xcode log parser at all. Now, in local environment I can confirm that LSP features works.
Next I'm going fix the issue with the parser seeing SwiftCompile
and swift-frontend
as an error ๐, which the main cause of "the decode function error" in neovim. I must've add catch all logic to treat any unrecognizable log as error, if that the case, ... what a bad decision it was.
Finally, with new release of xclog and updating the tag in xbase it should work flawlessly.
Great to hear! Thank you for the update. I'm glad you were able to crack it! Good job and thank you for your engagement! ๐ ๐
@wojciech-kulik please update your local version of xbase to latest version and should work without any issues ๐ค๐ค
I updated xbase, but I still get some errors:
Also, I have problems with LSP, I'm not sure if this is related with sourcekit-lsp or xbase but I'm never able to go to declaration/implementation or something like that.
For example:
- Open CommentsStateReducer.swift
- Go to line 22 and set the cursor over
dismissScreen
- Type
gd
,gD
,gI
,gr
- nothing works
Is it possible at all to make swift LSP work properly for iOS projects? I think I read somewhere that LSP doesn't understand project structure so it doesn't work across multiple Swift files. Is it true?
hmmm just to confirm, you did run make install in xbase root, right?
edit: also git pull
Is it possible at all to make swift LSP work properly for iOS projects? I think I read somewhere that LSP doesn't understand project structure so it doesn't work across multiple Swift files. Is it true?
Yes, and that's why xbase has it's own build server called sourcekit helper that solves these issues.
edit: my bad, for lsp to work now, you would need to remove .compile manually. It must be reading the old one (gets automatically updated on project structure change)
Oh, I didn't know I need to call make install
because it was in my config file. But once I did that it worked! ๐ Also LSP started working when I removed the .compile
file ๐.
Although I still have an issue when I try to run the app. When I use <leader>ef
and pick Run
I see an empty list:
LSP questions:
gd
works great, is it possible to see also references (gr
)? It doesn't work for me.- The same question for the implementation (
gI
) - for example, when I typegI
on the protocol method, is it possible to navigate to the implementation?
Improvements:
In Xbase logs it would be really nice to see a green message like Build succeeded
. Now it's a little bit hard to spot what's going on at the first glance:
Great job โค๏ธ
Congratulations ๐๐๐
Although I still have an issue when I try to run the app. When I use
<leader>ef
and pickRun
I see an empty list:
Yes, the empty list. I had the exact same issue and that led to #182. In my case I had "iPhone 13 Pro"
In simctl.iOS
list, which is outdated. If you have not configured it, it means a bug in the logic of processing custom configuration assuming it will always be non empty. Try adding
"iPhone 14 Pro"
and let me know
LSP questions:
gd
works great, is it possible to see also references (gr
)? It doesn't work for me.
Yeah in term of reference sourcekit it self lacks support, Xcode has custom setup to enable this. Please open a feature request for that. I will look into having the feature builtin.
- The same question for the implementation (
gI
) - for example, when I typegI
on the protocol method, is it possible to navigate to the implementation?
Not sure, but if it does not work, then same as the above.
Improvements:
In Xbase logs it would be really nice to see a green message like
Build succeeded
. Now it's a little bit hard to spot what's going on at the first glance:
Great suggestion, it should be super easy to implement (xbase has its own syntax highlighting for logs) please open a feature request.
This is my config:
I've got
iPhone 14
installed, but I'm still not seeing it on the list
I'm guessing you have different set of devices recognized by xbase. What is the output of lua print(vim.inspect(require"xbase.state"))
UPDATE:
Uhh, I missed iOS = { "iPhone 14" }.
Now It works!
Great the bug is confirmed, I will open an issue for that and push a fix soon to cover the case of empty configuration.
I updated my answer while you answered (now it works) ๐
I've got one last thing. Does xbase support xcworkspace? Most of my projects is using CocoaPods which generate xcworkspace
. I was trying to use xbase with my project and it doesn't work. My guess is that CocoaPods/xcworkspace is causing the problem.
You could reproduce it on this project:
https://github.com/wojciech-kulik/Swift-MVVMC-Demo
@wojciech-kulik Please feel free to close the issue if the problem is solved. The issue is getting too big๐ซข. Also don't forget feature requests for your suggestions
I updated my answer while you answered (now it works) ๐
I've got one last thing. Does xbase support xcworkspace? Most of my projects is using CocoaPods which generate
xcworkspace
. I was trying to use xbase with my project and it doesn't work. My guess is that CocoaPods/xcworkspace is causing the problem.You could reproduce it on this project:
Yes, I believe it is supported according to #86 and #101. I will double check it tomorrow and open an issue and mention you in case, it does not.