Recursive .headerSearchPath

I am developing the ObjC library for iOS and I want to migrate to SwiftPM from Xcode Project. The source code files of my library are grouped into folders by their functions.

 |   -|include/MyLibrary
 |    | MyLibrary.h
 |    | PublicHeader1.h
 |    | PublicHeader2.h
 |    ----
 |   -|Feature
 |    | FeatureClass.h
 |    | FeatureClass.m
 |    | -|Subfeature
 |    |  | SubfeautureClass.h
 |    |  | SubfeautureClass.m
 |    |  ----
 |    ----
 |    Class.h
 |    Class.m

But there is a problem that SPM requires all source code files to be in a flat structure (as far as I understood). There is a way to specify each folder in .headerSearchPath() in cSettings:. But my project has a lot of folders, so that's not an option. So I came up with the idea of using recursive search paths as in the Xcode project Build settings. So I added the following parameter to my SPM target:

cSettings: [

This solution works well with xcodebuild, but not with swift build.
It seems that xcodebuild understands that it must expose all folders from Sources/MyLibrary/** and inserts the following parameters in the Clang invocation:

clang -ISources/MyLibrary/Feature -ISources/MyLibrary/Feature/Subfeature

But swift build does not do this. It invokes Clang as follows:

clang -I/Path/To/Project/Sources/MyLibrary/**

Clang doesn't understand this search path and gives an error saying it can't find the required .h file.
I think swiftbuild should have the same behavior as xcodebuild.

I think the Xcode behavior is technically a bug here, the package manifest model currently does not define support for globbing. What's happening is likely that the string value is directly put into Xcode's native HEADER_SEARCH_PATHS build setting which does support this type of globbing.

1 Like

Well, I expected that

So is there any other solution for nested folders?