Skip to content

Undefined symbol errors when creating a custom request. #487

@ileitch

Description

@ileitch

Hey, I'm trying to create a custom request yet I'm getting undefined symbol errors for all of the sourcekitd functions. It looks like SourceKitten is dynamically loading the framework. Do I need to duplicate this process, or does SourceKitten expose a helper of some kind?

I'm using SourceKitten via Carthage.

func requestSymbolSuperclasses(_ kind: SymbolKind, name: String, usr: String) -> [String: Any] {
    let symbolOptions = [
        sourcekitd_uid_get_from_cstr("key.indexer.arg.symbol.name")!: sourcekitd_request_string_create(name),
        sourcekitd_uid_get_from_cstr("key.indexer.arg.symbol.kind")!: sourcekitd_request_string_create(kind.rawValue),
        sourcekitd_uid_get_from_cstr("key.indexer.arg.symbol.language")!: sourcekitd_request_string_create("Xcode.SourceCodeLanguage.Swift"),
        sourcekitd_uid_get_from_cstr("key.indexer.arg.symbol.resolution")!: sourcekitd_request_string_create(usr)
    ]

    var symbolOptionsKeys = Array(symbolOptions.keys.map({ $0 as sourcekitd_uid_t? }))
    var symbolOptionsValues = Array(symbolOptions.values)

    let dict = [
        sourcekitd_uid_get_from_cstr("key.request")!: sourcekitd_request_uid_create(sourcekitd_uid_get_from_cstr(RequestKind.symbolSuperclasses.rawValue)!),
        sourcekitd_uid_get_from_cstr("key.symbol")!: sourcekitd_request_dictionary_create(&symbolOptionsKeys, &symbolOptionsValues, symbolOptions.count)
    ]

    var keys = Array(dict.keys.map({ $0 as sourcekitd_uid_t? }))
    var values = Array(dict.values)
    let response: [String: Any]

    do {
        response = try Request.customRequest(request: sourcekitd_request_dictionary_create(&keys, &values, dict.count)!).send()
    } catch {
        fatalError("Symbol superclasses request failed: \(error)")
    }

    return response
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions