Need help with lldb-vscode plugin

I am trying to debug a swift vapor project in VSCode. I am trying to use the CodeLLDB extension to do this. Unfortunately, I am not able to use the default "lldb" executable properly because it does not have any swift "extensions". After some research I found the lldb-vscode plugin in the apple/llvm project under "lldb/tools".

What I don't know is how to build this tool. Do I have to build the entire project? Any help would be appreciated.

Thanks

Hi @bmontegani

See these installation instructions for VS Code on Linux: https://github.com/pwsacademy/swift-setup/blob/main/editors/vscode-linux/README.md

You can use the CodeLLDB extension with Swift, you just need to point it to a different LLDB library.

If you're using it on a Mac, also see the discussion on https://github.com/pwsacademy/swift-setup/issues/3, as the path to LLDB is different on Mac.

1 Like

I am using macOS Catalina with Xcode 12.3.
Here are my settings in VSCode:

"sourcekit-lsp.serverPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp",
"lldb.library": "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB"

Here is my code in Vapor:

import Vapor

func routes(_ app: Application) throws {
    app.get { req in
        return "It works!"
    }

    app.get("hello") { req -> String in
        return "Hello, world!"
    }

    app.get("message") { req -> String in
        let message = "A message"
        return message
    }
}

I put the break point on the line:
let message = "A message"

During debugging It stopped on this line. However, I cannot see any local variables in the debugger window. When I try to use the Debug Console issue the lldb command:

po message

I get the following error:

    error: <EXPR>:3:1: error: cannot find 'message' in scope
    message
    ^~~~~~~

I also noticed that at the bottom of the Debug Console in the input area it says:

Please start a debug session session to evaluate expressions

So even though it seems I am in a debug session because the app stops at the breakpoint it also seems that I am not in a debug session.

Any suggestions?

P.S. When I used a simple default generated package using swift package init like in the example you pointed me to it worked fine.

Here is some more information concerning this issue. I tried to run the lldb outside of VSCode. I started the debugger and then when I went to set the breakpoint I got a whole slew of errors:

❯ /Applications/Xcode.app/Contents/Developer/usr/bin/lldb .build/debug/Run
(lldb) target create ".build/debug/Run"
Current executable set to '/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run' (x86_64).
(lldb) breakpoint set -f routes.swift -l 14
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "App" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "AsyncHTTPClient" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "AsyncKit" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "Backtrace" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "COperatingSystem" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "ConsoleKit" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "CoreMetrics" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "Crypto" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "Logging" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "Metrics" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIO" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOConcurrencyHelpers" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOExtras" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOFoundationCompat" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOHPACK" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOHTTP1" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOHTTP2" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOHTTPCompression" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOSSL" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOTLS" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOTransportServices" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "NIOWebSocket" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "RoutingKit" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "Run" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "Vapor" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
warning: (x86_64) /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run unable to load swift module "WebSocketKit" (failed to get module "App" from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"
        ^

error: /Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"
         ^

error: could not build Objective-C module 'CNIOBoringSSLShims'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSLShims/include/CCryptoBoringSSLShims.h"
        ^

)
Breakpoint 1: where = Run`closure #3 (Vapor.Request) -> Swift.String in App.routes(Vapor.Application) throws -> () + 57, address = 0x0000000100004869
(lldb) po message
error: <user expression 1>:1:1: use of undeclared identifier 'message'
message
^

This (exact) issue happens to me too and I am currently working on fix (fixing my own project). I suspect this issue may be closely related to

and related bug report filed in jira. [SR-3169] lldb stops working when C module includes a header outside of module's include/ dir · Issue #4577 · apple/llvm-project · GitHub

This issue also could be related to SwiftPM and LLDB but unlike the first thread, I am not fully familiar with the content of this thread as I found at the time of writing this reply.

In case I find a way to solve the issue in my project, I will post here what helped me solve the issue. As for now, I’m going to follow this thread.

OK, I am back with the resolution for my issue.

Turns out my issue was not related to neither of linked thread, but I found solution in the latter thread. I have uploaded a repo containing my example GitHub - mikolasstuchlik/LldbMinimalTest.

I've tried following steps:

  • Clean the project using swift package clean
  • Build debug using swift build
  • Run my LLDB using /my/path/to/swift/from/swift-org/usr/bin/lldb .build/debug/LldbMinimalTest
  • Add breakpoint using breakpoint set --file main.swift --line 1

If any error ocurred when I set the breakpoint, I've tried another solution.

Turns out, that when target CGLib (which is system module) was added as a dependency directly to the executable target, lldb worked correctly. When I adeed CGLib as a dependency to a Swift target GLib and then added the target GLib as a dependency to the executable target, lldb failed.

I've configured LLDB according to Adrian's post and determined, that my issue was of a different nature than that of the OP of the thread.
Therefore I tried to call swift build with flags for frontend as described by Anthony and this solved my issue.

As I stated in the post above, my error message was exactly the same as yours, maybe the solution is worth trying for you aswell.

I have finalized my solution by addidng swiftSettings: [.unsafeFlags(["-Xfrontend", "-serialize-debugging-options"], .when(configuration: .debug))] argument to the (swift) GLib target which has CGLib as a direct dependency.

Hope this will help :slight_smile:

Good news!
I built my Vapor project using the following:

swift package clean
swift build -Xswiftc -Xfrontend -Xswiftc -serialize-debugging-options

I passed the recommended flags to the swift build command. All of these flags will be passed to all compiler invocations so no need to add to individual targets.

Here are the results of running lldb from the command line after the build:

❯ /Applications/Xcode.app/Contents/Developer/usr/bin/lldb .build/debug/Run
(lldb) target create ".build/debug/Run"
Current executable set to '/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run' (x86_64).
(lldb) breakpoint set -f routes.swift -l 14
Breakpoint 1: where = Run`closure #3 (Vapor.Request) -> Swift.String in App.routes(Vapor.Application) throws -> () + 57 at routes.swift:14:9, address = 0x0000000100004869
(lldb) r
Process 7361 launched: '/Users/bruce/dev/vapor/PracticalSSS/myProject/.build/debug/Run' (x86_64)
[ NOTICE ] Server starting on http://127.0.0.1:8080
[ INFO ] GET /message [request-id: 1D591F23-ED99-4457-9B3B-E22D7F3EABFE]
Process 7361 stopped
* thread #7, name = 'NIO-ELT-0-#5', stop reason = breakpoint 1.1
    frame #0: 0x0000000100004869 Run`closure #3 in routes(req=0x0000000101d076f0) at routes.swift:14:9
   11
   12  	    app.get("message") { req -> String in
   13  	        let message = "A message"
-> 14  	        return message
   15  	    }
   16  	}
Target 0: (Run) stopped.
(lldb) po req
GET /message HTTP/1.1
Host: localhost:8080
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Upgrade-Insecure-Requests: 1
Cookie: csrftoken=BHciilWm8K3auPMnl2qtJ7uPneQcwTGOo8rFxOhdovmkEwhK5UagJIP95JCK9msq
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Safari/605.1.15
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive


(lldb) po message
"A message"

As you can see I can display the two local variables in the closure. I will do some more testing and will also try it inside VSCode.

I will keep you informed. :grinning:

I'm not sure about the .unsafeFlags target swiftSettings you mentioned in the previous post. Is that specific to the issue you are having?

1 Like

Great news!

As stated in the documentation, .unsafeFlags are unsafe because using them can lead to exploits and the use of unsafe flags makes the products containing this target ineligible for use by other packages.

In contrast with the documentation, I haven't observed any problems related to having packaged with .unsafeFlags targets as it's dependenices. Maybe this applies for Xcode only or release builds... In any case, you don't have to use .unsafeFlags - I only used them as a quality of life improvement.

ok. I am not that knowledgeable on this topic. So you are saying that if you use the .unsafeFlags at the target level and in your case a specific configuration like debug then if you create a release version and tried to use the .unsafe flags then if this target is used in a product that depends on this target then other packages cannot use the product.

Is that correct?

So if I use the compiler flags at the build level this safety disappears? If I only use the build flags when building a debug version would that be ok?

Unfortunately, I don't know the answer. I am currently searching for the answer on the Forum, the Evolution page and the SPM repo.

I will post a new thread in the Forum asking for clarification, since the documentation heavily implies behavior which I do not observe.

@bmontegani

Hello, I'm back with my research into the matter. Usage of .unsafeFlags is discussed in Confused by unsafe flags being disallowed in dependencies and in this thread is a mention about PR "removing restriction on .unsafeFlags on local and branch dependencies".

Contrary to my previous post, I'm not going to open a new topic on the Forum since such topic already exists. I still don't feel like I understand completely all the implications of using .unsafeFlags and I think that the documentation should explain this feature better.

That said, I'm not going to start the duscussion now, as my time has run out for today :slight_smile: I will keep my eye on the issue and maybe looking into this in near future.