Skip to content

LanguageConfiguration fails to load queries in macOS 26 using SwiftPM #42

@BruceMcRooster

Description

@BruceMcRooster

When trying to run the README/documentation example code, an exception is raised when running

let swiftConfig = try! LanguageConfiguration(tree_sitter_swift(), name: "Swift")

The error is that it can't read the queries directory

Fatal error: 'try!' expression unexpectedly raised an error: SwiftTreeSitter.LanguageConfigurationError.queryDirectoryNotReadable(file:///path/to/build/directory/TreeSitterSwift_TreeSitterSwift.bundle/Contents/Resources/queries/

My best guess is that something changed in a recent macOS version regarding the output structure of bundle resources. When inspecting the actual file, TreeSitterSwift_TreeSitterSwift.bundle/queries exists with all the query files. This would thus work correctly if the platform was any other Apple platform based on the conditional compilation here:

#if os(iOS) || os(tvOS) || os(visionOS) || os(watchOS)
return bundlePath?.appendingPathComponent("queries", isDirectory: true)
#else
return bundlePath?.appendingPathComponent("Contents/Resources/queries", isDirectory: true)
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions