headerSearchPath issue

For a .headerSearchPath with multiple paths, Xcode is concatenating the paths into a single path and the builds are failing.

The directive works fine for building the package itself but fails when the package is imported into an Xcode 11 beta 2 app.

.headerSearchPath("$(SRCROOT)/Firebase $(SRCROOT)/GoogleUtilities/Logger/Private"), from https://github.com/firebase/firebase-ios-sdk/blob/5eb7513c7c5e2aa631c61c7ae309bce4dbe9ae98/Package.swift#L71.

From the Xcode build pane: -I/Users/paulbeusterien/Library/Developer/Xcode/DerivedData/StorageExample-akurljzskhottubesljyizrbemcs/SourcePackages/checkouts/firebase-ios-sdk/Firebase\ /Users/paulbeusterien/Library/Developer/Xcode/DerivedData/StorageExample-akurljzskhottubesljyizrbemcs/SourcePackages/checkouts/firebase-ios-sdk/GoogleUtilities/Logger/Private. Note the backslash space combination.

Any ideas or suggested workarounds?

I suspect .headerSearchPath is grammatically singular for a reason and the Package.swift is semantically incorrect. I believe it should actually be:

.headerSearchPath("$(SRCROOT)/Firebase"),
.headerSearchPath("$(SRCROOT)/GoogleUtilities/Logger/Private"),

See here for the documentation of headerSearchPath(_:_:).

1 Like

...and probably $(SRCROOT) doesn’t belong. The documentation says (emphasis added):

Provide a header search path relative to the target’s directory.

So I’m thinking the following is what it should be instead:

.headerSearchPath("../"), // From “Firebase/Core” to “Firebase”.
.headerSearchPath("../../GoogleUtilities/Logger/Private"),  // From “Firebase/Core” to “GoogleUtilities/Logger/Private”.

Thanks! Singular headerSearchPath's generates the right HEADER_SEARCH_PATH and fixes the build issue I was running into.

BTW, $(SRCROOT) is required. Otherwise swift package generate-xcodeproj will generate the wrong HEADER_SEARCH_PATHs.

Yes, I just confirmed that the generated Xcode project ends up with the unaltered strings. But I think that means there is a bug, either in the implementation or in documentation.

CC: @Aciid

1 Like
Terms of Service

Privacy Policy

Cookie Policy