Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-11427] Swift Package cannot depend on libxml2 from SDK reliably #4666

swift-ci opened this issue Sep 6, 2019 · 4 comments


Copy link

swift-ci commented Sep 6, 2019

Previous ID SR-11427
Radar rdar://problem/55066672
Original Reporter mremond (JIRA User)
Type Bug

XCode 11.0 beta 6 (11M392r) on Mac.

Swift version 5.0.2 (swift-5.0.2-RELEASE) on Linux.

Additional Detail from JIRA
Votes 1
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 2f9c0246a74459b446772053d0c4d921

Issue Description:

I have a library (Swift package) depending on libxml2.

The project builds properly under Xcode 11 beta, but cannot be build with SwiftPM without manually passing the include dir of the libxml2 headers.

If I issue just swift build it fails with the following error:

/Applications/ 'libxml/xmlversion.h' file not found

I have to use the following commands to build the project from command-line:

  • On MacOs:

    swift build -Xcc -I/Applications/
  • On Linux:

    swift build -Xcc -I/usr/include/libxml2

    The project is public and available here:

I expect that given the fact that I defined libxml2 as a dependency in the target, with linkerSettings, SwiftPM would know how to find one of its system library (from the SDK).

Here is the Package.swift that I used:

Copy link

belkadan commented Sep 6, 2019

This is really an Xcode issue rather than a SwiftPM issue, since the same customization is necessary to use libxml2 from an Xcode project. Can you file a Feedback with Apple as well? (It may get marked as a duplicate, admittedly, but including your use case can sometimes help prioritize bugs.)

Copy link
Contributor Author

swift-ci commented Sep 6, 2019

Comment by Mickaël Rémond (JIRA)

Xcode has some bug and I already filled a bug report for it to Apple but the issue is different.

Xcode can build the project by just opening the Package.swift file and builds it without customization.
However, it cannot build the project when the package is imported in Xcode in another project, and I could not find a way to build the project depending on such lib.

Copy link

daveanderson mannequin commented Sep 7, 2019

I'm having a similar issue attempting to leverage libxml2 in an Xcode + SPM situation. I've tried both Mikaël's approach and a modulemap approach. To no avail. Have filed feedback with sample project: FB7229118.

Copy link
Contributor Author

swift-ci commented Sep 11, 2019

Comment by Mickaël Rémond (JIRA)

I upgrade my setup to Xcode 11.0 GM: At least now, we have a consistent behaviour: Both Xcode or SwiftPM build cannot properly find the libxml2 headers.
Here is the Package.swift file:

So, it is unclear now how to properly set this up. Was the fact that Xcode was building fine the project a bug and what would be the preferred way to build a code depending on libxml2 ?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants