Thread 1: signal SIGABRT + libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

0

I have just started coding and am wondering how I can overcome this issue.

In the AppDelegate.swift file

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    return true
}

func applicationWillResignActive(_ application: UIApplication) {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

GameScene File

import SpriteKit
import GameplayKit

class GameScene: SKScene {

let player = SKSpriteNode(imageNamed: "rocket_launcher")
let enemy = SKSpriteNode(imageNamed: "attack_shuttle")

let gameArea: CGRect


override init(size: CGSize) {
    let maxAspectRatio: CGFloat = 16.0/9.0
    let playableWidth = size.height/maxAspectRatio
    let margin = (size.width-playableWidth)/2
    gameArea = CGRect(x: margin, y: 0, width: playableWidth, height: size.height)
    super.init(size: size)
}
required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}


func random() -> CGFloat {
    return CGFloat(Float(arc4random()) / 0xffffffff)
}
func random(min min: CGFloat, max: CGFloat) -> CGFloat{
    return random() * (max - min) + min
}




override func didMove(to view: SKView) {
    let background = SKSpriteNode(imageNamed: "background")
    background.size = self.size
    background.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
    background.zPosition = 0
    self.addChild(background)

    let foreground =  SKSpriteNode(imageNamed: "ufo_Background")
    foreground.size = gameArea.size
    foreground.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
    foreground.zPosition = 10
    self.addChild(foreground)


    player.setScale(1)
    player.position = CGPoint(x: self.size.width/2, y: self.size.height*0.10)
    player.zPosition = 2
    self.addChild(player)

    startNewLevel()
}



func startNewLevel(){
    let spawn = SKAction.run(spawnEnemy)
    let waitToSpawn = SKAction.wait(forDuration: 1)
    let spawnSequence = SKAction.sequence([waitToSpawn,spawn])
    let spawnForever = SKAction.repeatForever(spawnSequence)
    self.run(spawnForever)
}



func fireBullet(){

    let bullet = SKSpriteNode(imageNamed: "Starship_Rocket")
    bullet.setScale(1)
    bullet.position = player.position
    bullet.zPosition = 1
    self.addChild(bullet)

in CONSOLE

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)

I don't know how to overcome this issue. all my outlets are working. and none of the other pages were helpful. If anyone knows how to fix this, then please do let me know. Thanks

swift
xcode
sigabrt
nsexception
asked on Stack Overflow Mar 22, 2019 by Kaii Contractor Mehra • edited Mar 22, 2019 by Bhavin Kansagara

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0