Fix SPM consumer build: qualify cross-directory header imports (#215)#217
Conversation
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>
There was a problem hiding this comment.
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.
Fixes #215.
Problem
Adding iosMath as a Swift Package Manager dependency fails to build:
The bundled demo and
swift build/swift testall work, so the bug only hits downstream consumers.Root cause
Public headers in
render/imported sibling headers fromlib/by bare filename:That basename only resolves via the
libheader search path incSettings, which is target-internal — applied when SPM compiles iosMath's own sources, but not when a downstream consumer builds theiosMathClang module frommodule.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
render -> libimports aslib/MTMathList.hso they resolve from the package's public-headers root, which is exposed to consumers.Regression test
New
iosMathConsumerTeststarget importsiosMathpurely 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 — theircSettingscarry the internallib/renderpaths, 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