Skip to content

Support for Swift Package Manager #298

Closed

Description

@stefanhp

Is there a plan to support the Swift Package Manager in addition to CocoaPods ?

As of Swift 3, the language ships with SPM. For core-plot to support this mechanism, it would require:

  • Creating a Package.swift file to describe the module name, dependencies, exclusion etc...
  • Creating one or more module.modulemap files to map .h files to swift modules

This seems easy enough but the tricky part is with the multi-platform (OSX, iOS, tvOS) support with different includes, and possibly with file hierarchy.

Activity

  1. added this to the Release 2.2 milestone on Aug 29, 2016
  2. self-assigned this
    on Aug 29, 2016
  3. eskroch commented on Aug 30, 2016

    @eskroch
    Member

    According to the current package manager docs, "Note that at this time the Package Manager has no support for iOS, watchOS, or tvOS platforms." I'll see if I can get it working for the Mac, but we'll need to revisit this issue when support for other platforms is added.

  4. stefanhp commented on Sep 1, 2016

    @stefanhp
    Author

    If you're interested, I played around in a branch on our fork: feature/swift-package-manager.

    I got the dependency part to work (core-plot being a dependency of a test project), e.g. "swift build" checking out the correct version (note: you need to tag a commit with strict semantic versioning e.g. 2.2.0 for this to work). The Package.swift of the parent project:

    import PackageDescription
    
    let package = Package(
        name: "CorePlotGraph",
        dependencies: [
        .Package(url: "git@github.com:Myotest/core-plot.git", majorVersion: 2, minor: 2)
        ],
        exclude: ["Assets.xcassets", "Base.lproj" ]
    )

    I hit a wall with the module.modulemap business. I tried using a single module.modulemap file and just import the global header (CorePlot-CocoaTouch.h in this case) but it would not compile.
    I guess you would need either a more elaborate map, see the Swift Clang doc on Modules and modulemap grammar or one modulemap per .h file or group of .h files. Unfortunately, I do not understand the inner workings of core-plot, so understanding the cause was beyond the time I could spend on this.

    Let me know if I can help testing something.

    Note: Our project is in Swift 3, so I was using Xcode 8 beta 6 with Apple Swift version 3.0 (swiftlang-800.0.43.6 clang-800.0.38).

  5. eskroch commented on Sep 3, 2016

    @eskroch
    Member

    Xcode automatically generates a module map when building the Core Plot framework:

    framework module CorePlot {
        umbrella header "CorePlot.h"
    
        export *
        module * { export * }
    }
    
  6. removed this from the Release 2.2 milestone on Sep 15, 2016
  7. eskroch commented on Sep 15, 2016

    @eskroch
    Member

    I'm not sure the Core Plot project in its current form is compatible with the Swift Package Manager. It makes certain assumptions about the structure of the source directories that we do not follow. Also, Core Plot includes a Dtrace probe that needs to be compiled as part of the build process. I don't see any way to do that with the current version of the SPM.

    The probe may no longer be needed and we can rearrange the source files if necessary, but those changes will need to wait until after the 2.2 release is out the door.

  8. nidegen commented on Feb 10, 2020

    @nidegen

    What is the status on this? If the probe is not needed, I think the source dir structure should not be much of a problem:)

  9. eskroch commented on Feb 12, 2020

    @eskroch
    Member

    The probe was removed a while ago (before the 2.3 release). I haven't looked at the Swift package manager lately to see what else would be required to support it.

  10. slizeray commented on Aug 5, 2020

    @slizeray

    @eskroch Would it be possible to revisit this issue and give it a higher priority? SPM is now quite mature. Its major limitation was that it didn't support resources, but the latest version now does. Hence, more and more applications are going to adopt SPM. Thanks

  11. 3a4oT commented on Dec 10, 2020

    @3a4oT
    Contributor

    Seems like the source files structure is a major problem

  12. 3a4oT commented on Dec 12, 2020

    @3a4oT
    Contributor

    My attempt to add it at #436 cc. @eskroch

  13. eskroch commented on Dec 13, 2020

    @eskroch
    Member

    I merged pull request #436 on the release-2.4 branch. It looks ok to me but I'd appreciate some help with testing. Please make general comments here or open a new issue if you find specific problems that can be addressed separately.

  14. 3a4oT commented on Dec 13, 2020

    @3a4oT
    Contributor

    Thanks, @eskroch . #437 should fix one :)

  15. DivineDominion commented on Jan 22, 2021

    @DivineDominion
    Contributor

    Created an empty SwiftPM-managed project and successfully added CorePlot 👍 So for a first SPM support, it looks good enough to me. Doesn't break anything existing, and if users switch to SPM and encounter problems, I think it's better to collect issues during their transition than not releasing this at all. There's only so much one can do without a huge maintainer staff.

    Example Package file:

    let package = Package(
      name: "asd",
      platforms: [.macOS(.v10_12),],
        products: [
            .library(
                name: "asd",
                targets: ["asd"]),
        ],
        dependencies: [
          .package(name: "CorePlot", url: "https://github.com/core-plot/core-plot.git", .branch("release-2.4")),
        ],
        targets: [
            .target(
                name: "asd",
                dependencies: ["CorePlot"])
        ]
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions