Skip to content

Update sources in Package.swift to include scanner.c#330

Open
zxss702 wants to merge 1 commit intotree-sitter:masterfrom
zxss702:master
Open

Update sources in Package.swift to include scanner.c#330
zxss702 wants to merge 1 commit intotree-sitter:masterfrom
zxss702:master

Conversation

@zxss702
Copy link

@zxss702 zxss702 commented Feb 27, 2026

Description

This PR fixes a critical build issue when using this repository as a remote dependency via Swift Package Manager (SwiftPM).

The Issue

Currently, Package.swift uses FileManager.default.fileExists(atPath: "src/scanner.c") to conditionally append the scanner to the sources array. However, there is a known limitation with SwiftPM: when this package is included as a dependency in another project, SwiftPM evaluates relative paths based on the root project's working directory, not the dependency's directory.

Because of this, fileExists returns false, causing the scanner to be entirely omitted from the compilation process. This ultimately results in Undefined symbols for architecture... _external_scanner_... linker errors in downstream projects.

The Fix

  • Removed the dynamic FileManager check.
  • Explicitly declared src/scanner.c (and other required source files) in the sources array of the target.

This simple change ensures the package compiles correctly and links all required symbols regardless of how or where it is integrated via SwiftPM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant