1

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.

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
Jan
  • 907
  • 1
  • 8
  • 23

1 Answers1

1

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

0xTim
  • 5,146
  • 11
  • 23
  • Thanks! I have opened an issue on the project's GitHub page. Maybe I'll even find the time to create a PR myself. – Jan Jul 12 '18 at 06:57
  • Also, what makes you say it is untested ? Does this not run all all the tests on linux: https://github.com/malcommac/SwiftDate/blob/master/Tests/LinuxMain.swift ??? – Jan Jul 12 '18 at 07:27
  • 1
    Unfortunately not. That defines all of the test cases that should be run on Linux. However the `allTests` array isn't actually defined anywhere, so if you try and test that on Linux it will fail to compile. What needs to happen is each test case needs to define the array, and _all_ those arrays need to be added to LinuxMain.swift. E.g. https://github.com/brokenhandsio/vapor-oauth/blob/master/Tests/LinuxMain.swift – 0xTim Jul 12 '18 at 11:09
  • 1
    Additionally, the CI job for that project doesn't run on Linux, only macOS. So even if you _could_ run the tests on Linux, there's no guarantee they will work as they haven't been tested. (I'd put money on it crashing on Linux) – 0xTim Jul 12 '18 at 11:09