JamitLabs / Accio

A dependency manager driven by SwiftPM that works for iOS/tvOS/watchOS/macOS projects.
MIT License
664 stars 32 forks source link

Cache mixes up different Swift versions #61

Closed fredpi closed 5 years ago

fredpi commented 5 years ago

When caching frameworks, Accio differentiates between different Swift versions, so that a user having set Xcode 10.2.1 as their command line tools won't get cached frameworks originating from a user that has Xcode 11 set as their command line tools. That's needed, as otherwise, Xcode would complain that the frameworks have been built with Swift 5.1, while the user is still running Xcode 10.2.1 with Swift 5.0.1.

So, it's perfectly valid to separate by Swift version. However, the implementation doesn't work properly, as the Swift version is retrieved on compile time of Accio:

static var swiftVersion: String {
    #if swift(>=6.0)
        return "Swift-6.0"
    #elseif swift(>=5.2)
        return "Swift-5.2"
    #elseif swift(>=5.1)
        return "Swift-5.1"
    #elseif swift(>=5.0)
        return "Swift-5.0"
    #else
        return "Swift-4.2"
    #endif
}

This works quite often, as the Accio-compile-time Swift version is likely to match the current Swift version, but in transition periods (like now, switching from Swift 5.0 to Swift 5.1), this is a real issue: The folder that should store Swift 5.0 builds may now also include Swift 5.1 builds and the other way round.

To get things to work, the swift version should instead be retrieved via the swift --version command during runtime.

Jeehut commented 5 years ago

Absolutely correct. Would you mind fixing it? :)

fredpi commented 5 years ago

Will fix it with pleasure ;)