Skip to content
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

Configuration problem #178

Closed
wojciech-kulik opened this issue Apr 17, 2023 · 21 comments
Closed

Configuration problem #178

wojciech-kulik opened this issue Apr 17, 2023 · 21 comments

Comments

@wojciech-kulik
Copy link

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:
image

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:
image

I tried to follow debug steps but there are no logs.

@kkharji
Copy link
Owner

kkharji commented Apr 17, 2023

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")

@wojciech-kulik

This comment was marked as outdated.

@kkharji

This comment was marked as outdated.

@wojciech-kulik

This comment was marked as resolved.

@wojciech-kulik
Copy link
Author

wojciech-kulik commented Apr 17, 2023

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!

@wojciech-kulik

This comment was marked as outdated.

@kkharji
Copy link
Owner

kkharji commented Apr 18, 2023

@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.

@kkharji
Copy link
Owner

kkharji commented Apr 19, 2023

@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
}

@kkharji
Copy link
Owner

kkharji commented Apr 20, 2023

@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.

@wojciech-kulik
Copy link
Author

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! 🚀 🎊

kkharji added a commit to xbase-lab/xclog that referenced this issue Apr 21, 2023
Adds support for SwiftDriver compile commands. Note, This PR also remove escape chars from file-path of file list to fix error reading the file content. 

See: kkharji/xbase#178, kkharji/xbase#179
kkharji added a commit to xbase-lab/xclog that referenced this issue Apr 21, 2023
@kkharji
Copy link
Owner

kkharji commented Apr 22, 2023

@wojciech-kulik please update your local version of xbase to latest version and should work without any issues 🤞🤞

@wojciech-kulik
Copy link
Author

wojciech-kulik commented Apr 22, 2023

I updated xbase, but I still get some errors:

image

image

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:

  1. Open CommentsStateReducer.swift
  2. Go to line 22 and set the cursor over dismissScreen
  3. 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?

@kkharji
Copy link
Owner

kkharji commented Apr 22, 2023

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)

@wojciech-kulik
Copy link
Author

wojciech-kulik commented Apr 22, 2023

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:
image

LSP questions:

  1. gd works great, is it possible to see also references (gr)? It doesn't work for me.
  2. The same question for the implementation (gI) - for example, when I type gI 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:
image

Great job ❤️

@kkharji
Copy link
Owner

kkharji commented Apr 22, 2023

Congratulations 🎉🎉🎉

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:

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:

  1. 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.

  1. The same question for the implementation (gI) - for example, when I type gI 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.

@wojciech-kulik
Copy link
Author

wojciech-kulik commented Apr 22, 2023

This is my config:
image

I've got iPhone 14 installed, but I'm still not seeing it on the list

UPDATE:
Uhh, I missed iOS = { "iPhone 14" }. Now It works!

@kkharji
Copy link
Owner

kkharji commented Apr 22, 2023

This is my config:

image

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.

@wojciech-kulik
Copy link
Author

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

@kkharji
Copy link
Owner

kkharji commented Apr 22, 2023

@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

@kkharji
Copy link
Owner

kkharji commented Apr 22, 2023

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

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.

@wojciech-kulik
Copy link
Author

I added feature requests mentioned in this conversation: #188, #189, #190. Thank you one more time for all the help! Great job 🎊 🚀 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants