JamitLabs / Accio

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

Build error: 'Type' is only available on iOS 10.0 or newer #22

Closed khoogheem closed 5 years ago

khoogheem commented 5 years ago

when trying to do an install/update I am running into an error which comes up in the build logs.

`error: 'StringMeasurement' is only available on iOS 10.0 or newer the Project was set to 10.0 as minimum and even if I set it to 11 it still fails with these errors in the log file.

Jeehut commented 5 years ago

Hey @khoogheem, thank you for reporting this. Could you please post your full Package.swift file contents? This sounds like you're trying to build a framework which uses iOS 10.0 APIs but didn't have the deployment target set to iOS 10 properly. Could you please also copy more of the output here? Especially it's interesting to know, which framework Accio was trying to build when this error appeared and also which version of it.

khoogheem commented 5 years ago

Here is the projects Package

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "MyTarget",
    products: [],
    dependencies: [
        // add your dependencies here, for example:
        .package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver.git", from: "1.6.2"),
        .package(url: "https://github.com/FitnessKit/BluetoothMessageProtocol", from: "0.19.1"),
        .package(url: "https://github.com/FitnessKit/FitDataProtocol", from: "0.40.2")

    ],
    targets: [
        .target(
            name: "MyTarget",
            dependencies: [
                "SwiftyBeaver",
                "BluetoothMessageProtocol",
                "FitDataProtocol",
            ],
            path: "Source"
        ),
    ]
)

It will choke trying to get: https://github.com/FitnessKit/FitnessUnits which is a dependent of the Bluetooth and Fit packages...

Both the the packages inside of FitnessKit are still 4.X so they don't have the platforms defined

Jeehut commented 5 years ago

Okay, there you have it:

FitnessUnits .podspec file makes it clear that iOS 10 is the minimum required target. But FitnessUnits Package.swift file doesn't state that fact. Note that specifying minimum required versions are only possible starting with Swift 5, it was introduced just recently with SE-236. But Accio allows you to add it to Swift 4 projects as well by simply commenting that line out, Accio will take care of setting the target correctly then.

So, the fix for you is to fork FitnessUnits and add this line to the Package.swift file:

// platforms: [.iOS("10.0"), .macOS("10.12"), .tvOS("10.0"), .watchOS("3.0")],

For a full example of what such a Package.swift might look like and for further explanations, please read the "Adding support for Accio" section in the README.

I hope this helps.

khoogheem commented 5 years ago

ok... it was unclear that the commented out line actually would work... still in the process of moving things over to swift5

Jeehut commented 5 years ago

You mean, even after reading the docs it was unclear? Do you have a suggestion on how we could make it clearer? Feel free to post a PR with the text change. Also good luck with the move to Swift 5! :)

khoogheem commented 5 years ago

ok.. not sure If I still have something screwed up.. but two of my packages bring in this package https://github.com/FitnessKit/DataDecoder which I have set to iOS 10.. but it complains that it was built for 12.2

Jeehut commented 5 years ago

Again, please provide full output of both your manifest file and output. This sounds like the project already has a Xcode project file with a shared scheme whose target is set to 12.2.

Accio only uses the „platforms“ specified in the manifest if it needs to generate the Xcode project using SwiftPM for non-Carthage compatible frameworks. But if a framework has an Xcode project with a shared scheme, it is technically Carthage compatible and the existing scheme will be used as is. But Carthage users should actually come across the same issue in that case as you have, so its basically a project not properly conforming to Carthage and by that also to Accio.

I hope this info helps.

khoogheem commented 5 years ago

ok... I know where the problem is then thanks again

Jeehut commented 5 years ago

Sure, glad I could help.