Sourcekit-lsp xcframework binary target

Hi all.

I'm on macOS Tahoe, using MacVim with sourcekit-lsp. I have a Swift CLI project
that uses llama.cpp. I've pre-built llama.xcframework (part of llama.cpp) and
refer to it as a binary target in my CLI's Package.swift:

let package = Package(
    name: "llama1",
    targets: [
        .binaryTarget(
            name: "llama",
            path: "Binaries/llama.xcframework"
        ),
        .executableTarget(
            name: "llama1",
            dependencies: [.target(name: "llama")],
        ),
    ],
    swiftLanguageModes: [.v6]
)

The CLI program starts with import llama. Compilation works and the program
produces expected output. But sourcekit-lsp reports no such module 'llama',
and the editor can't goto definition nor (presumably) do other LSP stuff.

llama.framework looks like this:

% ls -l llama.xcframework
total 8
-rw-r--r--  1 talmeme  staff  3622 28 May 20:21 Info.plist
drwxr-xr-x  4 talmeme  staff   128 28 May 20:21 ios-arm64
drwxr-xr-x  4 talmeme  staff   128 28 May 20:21 ios-arm64_x86_64-simulator
drwxr-xr-x  4 talmeme  staff   128 28 May 20:21 macos-arm64_x86_64
drwxr-xr-x  4 talmeme  staff   128 28 May 20:21 tvos-arm64
drwxr-xr-x  4 talmeme  staff   128 28 May 20:21 tvos-arm64_x86_64-simulator
drwxr-xr-x  4 talmeme  staff   128 28 May 20:21 xros-arm64
drwxr-xr-x  4 talmeme  staff   128 28 May 20:21 xros-arm64_x86_64-simulator

In a macos-arm64_x64_64 subdirectory several levels deep is a module.modulemap:

framework module llama {
    header "llama.h"
    header "ggml.h"
    header "ggml-alloc.h"
    header "ggml-backend.h"
    header "ggml-metal.h"
    header "ggml-cpu.h"
    header "ggml-blas.h"
    header "gguf.h"
 
    link "c++"
    link framework "Accelerate"
    link framework "Metal"
    link framework "Foundation"
 
    export *
}

When building llama.cpp with cmake, I got it to CMAKE_EXPORT_COMPILE_COMMANDS
and have incorporated the generated compile_commands.json into my project; I
imagine this allows sourcekit-lsp to handle llama.cpp's source files. So just
the 'linkage' from sourcekit-lsp to 'framework module llama' is missing?

Is my best bet to incorporate llama.cpp by source inside my project?

Hi,

Are you passing any additional compiler arguments when building your package using swift build? If so, you’d also need to specify them in the SourceKit-LSP configuration file (sourcekit-lsp/Documentation/Configuration File.md at main · swiftlang/sourcekit-lsp · GitHub).