My question is a follow-up to How can I use Swift REPL with iOS SDK: I'd like to be able to drop into a REPL in an iOS project and use the classes defined there.
I've already built the project and it's running on a simulator:
Now, I'd like to start a standalone LLDB debugger for the iOS project, following these commands quoted from the answer above:
$ xcrun lldb -- $DerivedData/$AppName/Build/Products/Debug-iphonesimulator/$AppName.app
(lldb) process attach --name '$AppName' --waitfor
However, it is unclear to me what to substitute for $DerivedData
and $AppName
. The LLDB Quick Start guide, https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-terminal-workflow-tutorial.html, didn't help me much either, as the example just provides a path without explaining how you get that path.
I've also tried following the answers at https://apple.stackexchange.com/questions/171752/ios-simulator-installed-app-location-in-xcode-6-1, I've tried searching in the location below, but didn't find it there:
$ find . -name '*app'
./Developer/Library/Xcode/Agents/XCTRunner.app
$ pwd
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform
How do I find the .app
that is running on the simulator to launch lldb
with?
Update
As pointed out by Josh Caswell, DerivedData
is located in my home directory, and there I can find the app which is supposedly running on the simulator:
$ cd ~/Library/Developer/Xcode/DerivedData
$ find . -name '*Venmo.app'
./VenmoWorkspace-apbzqcexodswkdfenhxlkpnlmvsx/Build/Products/Debug-iphonesimulator/Venmo.app
The only problem is that if I try to run the repl
command, I get error: Can't run the REPL without a live process.
:
$ lldb ./VenmoWorkspace-apbzqcexodswkdfenhxlkpnlmvsx/Build/Products/Debug-iphonesimulator/Venmo.app
(lldb) target create "./VenmoWorkspace-apbzqcexodswkdfenhxlkpnlmvsx/Build/Products/Debug-iphonesimulator/Venmo.app"
Current executable set to './VenmoWorkspace-apbzqcexodswkdfenhxlkpnlmvsx/Build/Products/Debug-iphonesimulator/Venmo.app' (x86_64).
(lldb) repl
error: Can't run the REPL without a live process.
Why is the app running in the simulator not being 'picked up' as a live process?
Update 2
Reading the instructions more carefully, it seems I have to attach to the process first:
(lldb) process attach --name 'Venmo' --waitfor
The problem now is that this command is 'hanging'. Any idea why lldb
is not able to attach to the app's process?