Upgraded Playgrounds and existing Learn to Code projects wont run. What’s up?

After upgrading Swift Playgrounds app all of my saved exercise code in the Learn to Code apps will not complie and run. I get weird errors that make no sense given the code I am try to run..


Here’s the actual code



moveForward()

moveForward()

turnLeft()

moveForward()

moveForward()

collectGem()


and this generates the following errors


'Double.pi' or '.pi' to get the value of correct type and avoid casting.

Error: Contents/Sources/Color.swift:53: initializer 'init(colorLiteralRed:green:blue:alpha:)' has different argument names from those required by protocol '_ExpressibleByColorLiteral' ('init(_colorLiteralRed:green:blue:alpha:)')

Error: Contents/Sources/Gem.swift:117: type 'SCNAnimationProtocol' has no member 'spinAnimation'

Warning: Contents/Sources/Scene.swift:275: 'M_PI' is deprecated: Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.

Warning: Contents/Sources/Wall.swift:76: 'M_PI_2' is deprecated: Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.

Warning: Contents/Sources/Wall.swift:83: 'M_PI_2' is deprecated: Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.

Warning: Contents/Sources/HelperExtensions.swift:19: 'M_PI' is deprecated: Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.

Error: Contents/Sources/Color.swift:53: initializer 'init(colorLiteralRed:green:blue:alpha:)' has different argument names from those required by protocol '_ExpressibleByColorLiteral' ('init(_colorLiteralRed:green:blue:alpha:)')

Error: Contents/Sources/Gem.swift:117: type 'SCNAnimationProtocol' has no member 'spinAnimation'

Warning: Contents/Sources/Scene.swift:275: 'M_PI' is deprecated: Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.

Warning: Contents/Sources/Wall.swift:76: 'M_PI_2' is deprecated: Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.

Warning: Contents/Sources/Wall.swift:83: 'M_PI_2' is deprecated: Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.


how do I fix this?

Just apply the messages :


for pi, you need to provide the type, such as Float.pi or Double.pi

So write either :


var x = Double.pi
var y = Double.pi / 2
// or
var x, y : Double
x = .pi
y = .pi / 2


The init for defining colors has changed

Replace by:

let myColor = UIColor(red:0.1 , green: 0.2, blue: 0.5, alpha: 1.0)


Can you show the code where you call spinAnimation ? What does autocompletion proposes you when you start typing spin ?

Upgraded Playgrounds and existing Learn to Code projects wont run. What’s up?
 
 
Q