Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-322

Build MongoMobile with SwiftPM

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Do
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      This ticket might end up being an epic, but let's start here. MongoMobile is currently only tested using cocoapods' linting, which is less than ideal. I've added a test spec to cocoapods so the tests are at least run, but it would be far more convenient for future development for us to get this all working with SwiftPM. I spent a few hours yesterday trying to do this, and I think SwiftPM isn't quite up to the task yet. Here's what I tried:

      • installed mongo_embedded locally to my system, and added a pkg-config file
      • used the following updated Package.swift:

        // swift-tools-version:4.2
        import PackageDescription
        let package = Package(
            name: "MongoMobile",
            products: [
                .library(name: "MongoMobile", targets: ["MongoMobile"])
            ],
            dependencies: [
                .package(url: "https://github.com/mongodb/mongo-swift-driver.git", from: "0.0.7")
            ],
            targets: [
                .target(name: "MongoMobile", dependencies: ["MongoSwift", "mongo_embedded", "mongoc_embedded"]),
                .testTarget(name: "MongoMobileTests", dependencies: ["MongoMobile"]),
                .systemLibrary(name: "mongo_embedded", pkgConfig: "mongo-embedded"),
                .systemLibrary(name: "mongoc_embedded", pkgConfig: "mongo-embedded")
            ]
        )
        

      This results in being able to compile MongoMobile without any code modifications, however we are unable to actually link properly when running the tests. This is because there is no current way to add an rpath to the resulting test binary automatically, and the frameworks linked to by embedded depend on being able to find the dynamic libraries based on rpath.

      I think we'll have a much better shot at getting this working once this proposal is implemented. It's already been accepted, so I imagine this comes out relatively soon.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            matt.broadstone Matt Broadstone
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: