Skip to content

Fix SPM consumer build: qualify cross-directory header imports (#215)#217

Merged
kostub merged 1 commit into
masterfrom
fix/spm-cross-directory-header-import
Jun 7, 2026
Merged

Fix SPM consumer build: qualify cross-directory header imports (#215)#217
kostub merged 1 commit into
masterfrom
fix/spm-cross-directory-header-import

Conversation

@kostub
Copy link
Copy Markdown
Owner

@kostub kostub commented Jun 7, 2026

Fixes #215.

Problem

Adding iosMath as a Swift Package Manager dependency fails to build:

fatal error: 'MTMathList.h' file not found
... could not build module 'iosMath'

The bundled demo and swift build/swift test all work, so the bug only hits downstream consumers.

Root cause

Public headers in render/ imported sibling headers from lib/ by bare filename:

// render/MTMathUILabel.h
#import "MTMathList.h"   // actually lives in lib/

That basename only resolves via the lib header search path in cSettings, which is target-internal — applied when SPM compiles iosMath's own sources, but not when a downstream consumer builds the iosMath Clang module from module.modulemap. The consumer's module build only has the public-headers root on its include path, so the cross-directory include fails. (Xcode 16's explicit-modules dependency scanning surfaces it as the error above.)

Fix

  • Qualify the render -> lib imports as lib/MTMathList.h so they resolve from the package's public-headers root, which is exposed to consumers.
  • Add that root to each target's header search paths so internal builds keep resolving the qualified path.

Regression test

New iosMathConsumerTests target imports iosMath purely as a Clang module with no header search paths, reproducing exactly how an external SPM consumer builds it. The existing test targets can't catch this — their cSettings carry the internal lib/render paths, which leak into the implicit module build and mask the bug.

Verified RED/GREEN: reverting one header to the bare import makes the new target fail with the exact #215 error; with the fix it passes. Full suite: 267 tests, 0 failures.

🤖 Generated with Claude Code

Public headers in render/ imported sibling headers from lib/ by bare
filename (e.g. `#import "MTMathList.h"`). That only resolves via the
target-internal `lib` header search path, which is applied when building
iosMath's own sources but NOT when a downstream SPM consumer builds the
`iosMath` Clang module from module.modulemap. Consumers therefore failed
with "'MTMathList.h' file not found" / "could not build module 'iosMath'",
while the bundled demo and in-package tests worked.

Qualify the render -> lib imports as `lib/MTMathList.h` so they resolve
from the package's public-headers root (exposed to consumers), and add
that root to each target's header search paths so internal builds keep
resolving the qualified path.

Add `iosMathConsumerTests`, a test target that imports iosMath purely as
a Clang module with no header search paths, reproducing external SPM
consumption. It fails to compile if a bare cross-directory import returns.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request resolves issue #215 by fixing cross-directory header imports. Specifically, it updates several public headers in the render/ directory to import MTMathList.h using the relative path lib/MTMathList.h instead of a bare filename. Additionally, it updates Package.swift to include appropriate header search paths and introduces a new regression test target, iosMathConsumerTests, to ensure external consumers can build the module without internal search paths. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@kostub kostub merged commit 2685b60 into master Jun 7, 2026
1 check passed
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.

Clang dependency scanning failure, fatal error: MTMathList.h not found.

1 participant