Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let package = Package(
],
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("."),
.headerSearchPath("lib"),
.headerSearchPath("render"),
.headerSearchPath("render/internal"),
Expand All @@ -33,6 +34,7 @@ let package = Package(
path: "iosMathTests",
exclude: ["en.lproj"],
cSettings: [
.headerSearchPath("../iosMath"),
.headerSearchPath("../iosMath/lib"),
.headerSearchPath("../iosMath/render"),
.headerSearchPath("../iosMath/render/internal"),
Expand All @@ -43,6 +45,7 @@ let package = Package(
dependencies: ["iosMath"],
path: "iosMathSwiftTests",
cSettings: [
.headerSearchPath("../iosMath"),
.headerSearchPath("../iosMath/lib"),
.headerSearchPath("../iosMath/render"),
.headerSearchPath("../iosMath/render/internal"),
Expand All @@ -51,5 +54,14 @@ let package = Package(
.swiftLanguageMode(.v5),
]
),
// Regression guard for issue #215. Imports `iosMath` purely as a Clang
// module with NO header search paths, reproducing how an external SPM
// consumer builds the module. If a public header reintroduces a bare
// cross-directory `#import`, this target fails to compile.
.testTarget(
name: "iosMathConsumerTests",
dependencies: ["iosMath"],
path: "iosMathConsumerTests"
),
]
)
2 changes: 1 addition & 1 deletion iosMath/render/MTFontManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@import CoreText;

#import "MTFont.h"
#import "MTMathList.h"
#import "lib/MTMathList.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion iosMath/render/MTMathListDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#import "MTConfig.h"

#import "MTFont.h"
#import "MTMathList.h"
#import "lib/MTMathList.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion iosMath/render/MTMathUILabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import "MTConfig.h"

#import "MTFont.h"
#import "MTMathList.h"
#import "lib/MTMathList.h"
#import "MTMathListDisplay.h"

/**
Expand Down
41 changes: 41 additions & 0 deletions iosMathConsumerTests/iosMathModuleConsumerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// iosMathModuleConsumerTests.swift
// Regression test for issue #215: "Clang dependency scanning failure,
// fatal error: MTMathList.h not found."
//
// This target deliberately depends on `iosMath` and imports it *purely as a
// Clang module*, with NO header search paths configured in Package.swift. That
// reproduces exactly how a downstream Swift Package Manager consumer builds the
// module: from `module.modulemap` against the package's public-headers root,
// without iosMath's target-internal `lib`/`render` search paths.
//
// The bug was that public headers in `render/` imported sibling headers in
// `lib/` by bare filename (e.g. `#import "MTMathList.h"`), which only resolves
// when the internal `lib` search path is present. External consumers (and this
// target) lack that path, so building the module failed with
// "'MTMathList.h' file not found".
//
// If that regression returns, this target FAILS TO COMPILE — `import iosMath`
// forces the module (all module-map headers) to build. The assertions below are
// secondary; the real guard is that this file compiles at all. Referencing a
// `render/` type (MTMathUILabel) and a `lib/` type (MTMathList) together keeps
// the cross-directory include in the compiled surface.

import XCTest
import iosMath

final class iosMathModuleConsumerTests: XCTestCase {

// Exercises the render -> lib cross-directory include path. MTMathUILabel
// lives in render/ and pulls in MTMathList from lib/.
@MainActor
func testModuleBuildsAndRendersCrossDirectoryTypes() {
let label = MTMathUILabel()
label.latex = #"\frac{1}{2}"#
XCTAssertNotNil(label.mathList)
XCTAssertNil(label.error)

// Use the lib/ type directly as well so it stays in the consumed surface.
let list: MTMathList? = label.mathList
XCTAssertNotNil(list)
}
}
Loading