I’m trying to use lldb to debug a project from a test target. I started lldb pointing to the .xctest target
lldb .build/debug/JPEGPackageTests.xctest
and I got this error when i tried to inspect variables inside the code i’m trying to debug
(lldb) p s
warning: Swift error in module JPEGPackageTests.xctest.
Debug info from this module will be unavailable in the debugger.
error: in auto-import:
failed to get module 'JPEG' from AST context
Apologies for hijacking this thread, but I've been trying to figure out how to launch the unit tests with lldb, and I'm not getting anywhere.
If you start lldb pointing at an .xctest bundle, is a simple run supposed to be sufficient to kick it off? I just get:
Test > lldb .build/debug/TestPackageTests.xctest
(lldb) target create ".build/debug/TestPackageTests.xctest"
Current executable set to '.build/debug/TestPackageTests.xctest' (x86_64).
(lldb) run
error: failed to launch or debug process
(lldb)
For simplicity create new package
mkdir SwiftModuleHelloWorld
cd SwiftModuleHelloWorld
swift package init
Run tests to determine how xctest run your test (and get right path) $ swift test -v
Run lldb using path from output above (change to your path): $ lldb /Applications/Xcode.app/Contents/Developer/usr/bin/xctest /Users/anton/Desktop/sources/SwiftModuleHelloWorld/.build/x86_64-apple-macosx/debug/SwiftModuleHelloWorldPackageTests.xctest
Try run all test from lldb (lldb) process launch
Set breakpoint on single test (lldb) breakpoint set -f SwiftModuleHelloWorldTests.swift -l 9
Run it again (lldb) process launch
Breakpoint was hit, now you can use inspecting commands