Skip to content

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

Open

Description

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

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/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.0.sdk/usr/include/libxml2/libxml/HTMLparser.h:15:10: '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/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2
  • On Linux:

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

    The project is public and available here: https://github.com/FluuxIO/XMPP

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: https://github.com/FluuxIO/XMPP/blob/master/Package.swift

Activity

  1. belkadan commented on Sep 6, 2019

    @belkadan

    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.)

  2. swift-ci commented on Sep 6, 2019

    @swift-ci
    ContributorAuthor

    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.

  3. daveanderson commented on Sep 7, 2019

    daveandersonmannequin
    Mannequin

    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.

  4. swift-ci commented on Sep 11, 2019

    @swift-ci
    ContributorAuthor

    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: https://github.com/FluuxIO/XMPP/blob/master/Package.swift

    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 ?

  5. transferred this issue fromswiftlang/swifton May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions