Using LLDB with iOS Simulator from CLI

I've attempted to run lldb from a shell and select an already booted & running simulator, but lldb can't "see" it:

$ xcrun lldb # or simply `lldb`
(lldb) platform select ios-simulator
  Platform: ios-simulator
    Triple: x86_64h-apple-macosx
OS Version: 10.15.3 (19D76)
    Kernel: Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64
  Hostname: 127.0.0.1
WorkingDir: /Users/vvalekseev/Developer/avito-ios/Avito
  SDK Path: "/Applications/Xcode_11_3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
No devices are available.
(lldb) platform connect <UDID>
error: no device with UDID or name '<UDID>' was found

xcrun simctl list shows that UDID as booted.

Is there something specific I have to do in order to make lldb work with simulators?

Somebody sent me this link: https://bugs.llvm.org/show_bug.cgi?id=36580

Does it mean this functionality does not work for quite a while now?

I encountered this.
Although I didn't find a solution to platform connect successfully,
I found it unnecessary actually.
I tried the line in Xcode's lldb, it gave me the same error.
But somehow I can debug with Xcode apparently.
Thus, I tried

xcrun lldb <path to my .app file>
(lldb) process attach -n <name of my app> -w  // wait for app to launch
// launch the app in simulator

Also, this works

xcrun simctl launch <com.company.app>
<process id output>
(lldb) process attach -p <process id output>

It turned out we don't need to connect to the simulator before we attach to a process.

Hope this helps.

Thanks, but I was up to use the most recent versions of lldb, not the one that is being shipped with Xcode. Do you know a way to point Xcode to a different lldb?

I am a little confused.
Base on the title of this thread, you want to use lldb from CLI.
Why is Xcode involved here?

As far as I can tell, there is a clear way to use lldb with simulator from Xcode. But not from command line.

I think there are some words of mine misunderstood.
I brought up Xcode just to point out that
if a problematic lldb can work WITHIN Xcode,
it should be able to work WITHOUT as well.

My lines work without the prefix xcrun.

> lldb <path to .app>
(lldb) process attach -n <name of app> -w
1 Like

Ah, I see, totally makes sense, thanks a lot for pointing out to this!

Terms of Service

Privacy Policy

Cookie Policy