Search code examples
swiftxcodevaporswift-package-managerswiftdate

Cannot add SwiftCalendar as a dependency in vapor3 project via package manager


I am currently trying to add SwiftDate to a Vapor3 project via the swift package manager. Here is my package file:

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "timeshare",
    dependencies: [
        // 💧 A server-side Swift web framework.
        .package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
        // Custom dependencies
        .package(url: "https://github.com/malcommac/SwiftDate.git", from: "5.0.0"),
    ],
    targets: [
        .target(name: "App", dependencies: ["Vapor", "SwiftDate"]),
        .target(name: "Run", dependencies: ["App"]),
        .testTarget(name: "AppTests", dependencies: ["App"]),
    ]
)

However, when I try to build my project I get 82 issues in Xcode (all from the SwiftCalendar module). For example this:

Example Error

I have no idea how I can possible have caused errors in a third party library. Any input is highly appreciated.

Thanks

More errors can be seen here:

enter image description here

PS: Sorry for including screenshots, I know they might be hard to read, but I could not find a way to copy the error list as text.


Solution

  • The project isn’t in the correct format for SPM. All the files need to be declared in the correct target directory, but DateRepresentable is outside of that https://github.com/malcommac/SwiftDate/tree/master/Sources

    It’s also worth noting that this doesn’t seem to have any tests on Linux and involves DateManipulation. I’d be very weary about using it since Dates on Linux are notoriously crashy