Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: cannot convert value of type 'T.IndexDistance' to expected argument type 'Int' #91

Closed
pohetsn opened this issue Oct 23, 2018 · 8 comments

Comments

@pohetsn
Copy link

pohetsn commented Oct 23, 2018

I've encountered the following error message when building Surge with Carthage. My environment is Xcode 9.2, and I have github "mattt/Surge" ~> 2.1.0 in the Cartfile. Not sure where the T.IndexDistance comes from. Thanks for the help

<project path>/Carthage/Checkouts/Surge/Sources/Surge/Matrix.swift:41:34: error: cannot convert value of type 'T.IndexDistance' to expected argument type 'Int'
        self.init(rows: contents.count, columns: contents.first!.count, repeatedValue: 0.0)
                        ~~~~~~~~~^~~~~
                        Int(          )
@mattt
Copy link
Collaborator

mattt commented Oct 23, 2018

IIRC, Swift 4 changed the semantics for collection index distances such that they're now Int, whereas before they were a generic IndexDistance type. Can you please confirm that your project is compiling with Swift 4 and not Swift 3?

@alejandro-isaza I just noticed that Surge doesn't specify any Swift language requirements in the README (though we do have a .swift-version file). It'd be great to make the Swift (and Xcode) version requirements explicit.

@pohetsn
Copy link
Author

pohetsn commented Oct 23, 2018

I see. Thanks for your prompt response.

If I type swift --version, it returns

Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9

But how should I make sure Carthage is using this version? In Xcode Build Settings, I can change Swift Language Version between 3.2 and 4.0. But it doesn't affect the swift version shown in the command line. Sorry I'm new in this. Thanks for your help.

@pohetsn
Copy link
Author

pohetsn commented Oct 23, 2018

Btw, I also tried CocoaPod to install Surge. In Xcode, I had Build settings > Swift Language Version > Swift 4.0. It shows the same error message.

@alejandro-isaza
Copy link
Collaborator

I have never seen this. Make sure you have the latest version of CocoaPods. Alternatively if you can share your project I can have a look.

@pohetsn
Copy link
Author

pohetsn commented Oct 24, 2018

My cocoa pods version is 1.5.3. So it is fairly recent. Btw, I tried to install Surge on another machine that uses Xcode 9.4.1 and Swift version 4.1.2, and Surge was installed without any error. I think DistanceIndex was taken out at 4.1 instead of 4.0 (see here). So maybe the .swift-version file should be updated to 4.1?

@alejandro-isaza
Copy link
Collaborator

Ah, good catch. That's probably it. Will update to 4.1.

@alejandro-isaza
Copy link
Collaborator

Pushed 2.2.0 to CocoaPods

@mattt
Copy link
Collaborator

mattt commented Oct 25, 2018

👏 Thanks, @alejandro-isaza!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants