tbointeractive / bytes

bytes is a set of Swift tools to cover many all-day tasks in iOS development.
MIT License
7 stars 1 forks source link

Bool.random function is ambiguous in XCode 10 - beta 2 #23

Closed LukasLiebl closed 6 years ago

LukasLiebl commented 6 years ago

Hey,

I just discovered an issue with the .random() function in the extension for Bool. If you want to use it in XCode 10 Beta 2 (I guess it is also valid for beta 3 - but I didn't test that) XCode complains about an "ambiguous use of 'random()'".

brototyp commented 6 years ago

I guess we have a name conflict here. Swift 4.2 defines a (for swift unavailable) Bool.random(using: &RandomNumberGenerator). @achelsmar Do you know a way to define our Bool.random only for swift < 4.2?

pstued commented 6 years ago

I think this could help: https://github.com/apple/swift-evolution/blob/master/proposals/0141-available-by-swift-version.md

But haven't used it yet.

brototyp commented 6 years ago

It does! Awesome! I wasn't aware of the obsoleted parameter here. Unfortunately there is this stupid (not really, but it makes my life hard right now) compatibility layer. So depending on which Xcode version you are using the Bool.random() is defined (by swift) or not. If you use Xcode 10 with Swift 4 it is defined, if you use Xcode 9 with Swift 4 it is not. Unfortunately the only Idea I have is to add a @available(swift, obsoleted: 4), where then it only is available for swift versions smaller than 4 (which doesn't make to much sense, since it wouldn't build at all).

brototyp commented 6 years ago

What do you think about creating a 4.2 branch, removing this function there and keeping it on the side as long as 4.2 is not released?

pstued commented 6 years ago

Sure. We can do that. But as far as I remember bytes is still on swift 3.2, isn't it? So how about convert develop to Swift 4.1 And then create a swift4.2 branch.

brototyp commented 6 years ago

Develop is actually already on 4.1 😊

brototyp commented 6 years ago

This just got merged.