Why does the header search path configured in Package.swift shouldn't be outside the package?

case .invalidHeaderSearchPath(let path):
            return "invalid header search path '\(path)'; header search path should not be outside the package root"

In my project, we usually add the path outside the source file directories, such as upper directory. Due to the error, I can't use Package.swift to change my project dependency management into Swift Package Manager. So sad.

I think it's quite unreasonable : (

1 Like

If it's outside the package, how would a package that depends on it be able to pull in the headers?

Obviously it’s a problem for remote dependencies, but since SPM supports local dependencies as well, it seems like it should work there, no?

I'm guessing SwiftPM packages are designed as self contained blobs so this would break it (system dependencies aside)

1 Like

The structure of my project is more like centralized, different modules are managed in the same directory. To reduce the compile time cost, we use static library for modules which shouldn't participate in compilation, and main App only link it when compiling. I want to try Swift Package to improve the integration of my project, but it's seems that it is not easy as I thought.

What I confused most is that, Package.swift is more like a method to replace *.xcodeproj. But it doesn't have the same skill as *.xcodeproj. If I will develop a new project/App I prefer use Swift Package to manage the dependency, but it is not friendly for old project to integrate, I think.

I found that symbolic link could solve the problem.

cd [folder of the package.swift]
ln -s ../../TargetHeadersPath myInclude


// for your target setting
.cxxSettings: [
1 Like

Cool! Thanks for reply, I will try it.