Search code examples
iosswiftxcode10

Swift 4.2 Syntax change - What happened to Swift type inference?


I'm running Xcode 10 beta with Swift 4.2. Xcode wants to convert my Xcode 9.4.1 with Swift 4.1 code to Swift 4.2 syntax. The changes are all UIView.animate(... options: ...).

I using options like .curveEaseIn which worked fine before but it wants to change them to UIView.AnimationOptions.curveEaseIn.

What happened to Swift's ENUM type inference?


Solution

  • It was UIViewAnimationOptions.curveEaseIn in Swift 4.1. So, the migrator has detected your .curveEaseIn as UIViewAnimationOptions.curveEaseIn and trying to convert it to UIView.AnimationOptions.curveEaseIn.

    Seems current migrator does not like dot-leaded notation.

    You can convert all occurrences of UIView.AnimationOptions.curveEaseIn into .curveEaseIn manually, and Swift type inference would work if appropriate.

    You may want to write a feature request proposing improvement of the migrator.


    (Addition) Seems Xcode 10 beta 3 has fixed this issue, though I have not tested yet.

    Xcode 10 beta 3 Release Notes