wojciech-kulik / xcodebuild.nvim

Neovim plugin to Build, Debug, and Test applications created for Apple devices (iOS, macOS, watchOS, etc.)
MIT License
696 stars 18 forks source link

Could not connect codelldb #139

Closed BlackCatHehe closed 7 months ago

BlackCatHehe commented 7 months ago

Hello, all functionalities work fine when I use xcodebuild. However, I encounter errors when I run in debug mode.

I've correctly configured the codelldb path according to the sample project, and during the first debug, I was prompted to address codelldb's privacy concerns. However, subsequent runs present the problem as shown in the image below.

The configurations for nvim-dap and nvim-dap-ui are directly copied from the sample project.

I'm new to nvim, could you help me figure out what might be causing this issue?

image image image image
wojciech-kulik commented 7 months ago

Hmm, that's weird, your configuration seems fine. Are you sure you downloaded codelldb for the correct architecture?

What happens if you run from the command line:

./codelldb --port 13000   
BlackCatHehe commented 7 months ago

My Mac is M3, and the version I downloaded is this one.

image

When I directly run the command you provided under the codelldb file, the system prompts me to verify the privacy security of liblldb.dylib and libpython39.dylib first. After verification, it just gets stuck there without any response.

image
wojciech-kulik commented 7 months ago

Weirdly, it asks you about privacy security. Maybe some firewall settings or something like that?

It should stuck, because it's just running the server.

Do you have this file:

/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB

Can you also check this command:

./codelldb --port 13000 --liblldb "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB"

?

BlackCatHehe commented 7 months ago

I tried again. I directly ran the following command in the terminal:

./codelldb --port 13000

Then, when using the xcodebuildDebug command, lldb can connect properly. However, when I stop the project from running, the codelldb running in the terminal also stops. At this point, I can't connect using xcodebuildDebug for two consecutive attempts.

I downloaded my Xcode from xcodesapp, and it comes with version numbers, like this:

image
wojciech-kulik commented 7 months ago

Ok, in this case I think you should report this issue in nvim-dap repository if it works when you manually run codelldb. The process is managed by nvim-dap, the only thing xcodebuild does is to provide the configuration:

  return {
    type = "server",
    port = "13000",
    executable = {
      command = codelldbPath,
      args = {
        "--port",
        port or "13000",
        "--liblldb",
        lldbPath or "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB",
      },
    },
  }
wojciech-kulik commented 7 months ago

Oh, but wait, I just noticed that you've got a different path: /Applications/Xcode-15.2.0.app. So you need to provide the config manually.

Just add below xcodebuild.setup(codelldbPath) in nvim-dap config:

require("dap").adapters.codelldb = xcodebuild.get_codelldb_adapter(codelldbPath, "/Applications/Xcode-15.2.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB")
BlackCatHehe commented 7 months ago

It seems the issue is caused by the inability to start codelldb properly when I use xcodebuild debug-related commands.

Oh, but wait, I just noticed that you've got a different path: /Applications/Xcode-15.2.0.app. So you need to provide the config manually.

Just add below xcodebuild.setup(codelldbPath) in nvim-dap config:

require("dap").adapters.codelldb = xcodebuild.get_codelldb_adapter(codelldbPath, "/Applications/Xcode-15.2.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB")

It worked! Thank you!

jaekong commented 2 months ago

For people finding this later:

I had the same error message, but it was from different cause.

export LC_CTYPE=en_US.UTF8 # or some other locale

I needed LC_CTYPE environment variable set up.

wojciech-kulik commented 2 months ago

@jaekong out of curiosity, how did you figure it out to define that env? :D