ah786
ah786

Reputation: 71

game works on iOS 8 but crashes in iOS 7

I'm almost done developing my game and it works perfectly on iOS 8, but I changed the deployment target to iOS 7.1 and tried running it on iOS 7.1 simulator, the game crashes. Any reason why is that? I have used swift as the programming language.

The error is "thread 1:signal SIGABRT"

Edit 1: It seems that it crashes when I add an SKLabelNode. here is the function which adds a score label :

var scoreLabel = SKLabelNode()

func addScoreLabel() {

    scoreLabel = SKLabelNode(text: "Score: \(score)")
    scoreLabel.fontSize = 25

    let xPos = size.width/2 //- gameOverHUD.size.width/5
    let yPos = size.height/2 //+ gameOverHUD.size.height/2 - 5

    scoreLabel.position = CGPoint(x: xPos, y: yPos)
    addChild(scoreLabel)

}

This is the complete error I get in the output console:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SKLabelNode labelNodeWithText:]: unrecognized selector sent to class 0x10f22a3a0'

Edit 2: I was able to fix it. In case anyone is facing the same problem, simply replace the 'scoreLabel = SKLabelNode(text: "Score: (score)")' with scoreLabel.text = "Score: (score)").

Upvotes: 1

Views: 239

Answers (1)

hamobi
hamobi

Reputation: 8130

check this out

https://developer.apple.com/library/prerelease/ios/documentation/SpriteKit/Reference/SKLabelNode_Ref/index.html#//apple_ref/occ/clm/SKLabelNode/labelNodeWithText:

labelNodeWithText is only available for iOS 8 and later. It wont work for iOS 7. You could instead go:

let label = SKLabelNode()  // or SKLabelNode(fontNamed: "whatever")
label.text = "hey there"

Upvotes: 1

Related Questions