Trouble instantiating SKSpriteNode in Xcode9 and simulator

I switched to XCode 9 and my code crashes when run in the simulator.

When run on a real device or when run in XCode 8 it works fine.

When I step through the app and look at the simulator the screen is NOT cleared when self.removeAllChildren is called. Is this an async method? Can I wait for this method to complete?



func drawCards(hand:[String], trick:[String]) {

self.removeAllChildren()

if (hand.count > 0) {

for index in 0...(hand.count-1) {

var xPosition = size.width

let relativePosition = CGFloat(CGFloat(-hand.count) / 2.0 + CGFloat(index)) * 0.05

xPosition *= ( 0.525 + relativePosition)

var yPosition = size.height

yPosition *= 3 * (cos(relativePosition * 0.5) - 1) + 0.05

let card = SKSpriteNode(imageNamed: hand[index]) // This is where the app crashes after the loop is called the second time

card.position = CGPoint(x: xPosition, y: yPosition)

card.zRotation = -20 * CGFloat.pi / 180 * relativePosition

card.scale(to: CGSize(width: 125, height: 182))

card.zPosition = CGFloat(index)

card.name = hand[index]

addChild(card)

}

}

}