Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift error : signal SIGABRT how to solve it

Tags:

ios

swift

I'm just a beginner in Swift coding. My idea is quite simple which is an app with two buttons. When clicked, a textfield will change its text. In the Main.StoryBoard, I add a textfield and two buttons. In ViewController.swift file. I write as this:

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var textfield: UITextField!
    @IBOutlet weak var button: UIButton!
    @IBOutlet weak var button2: UIButton!

    @IBAction func action1(_ sender: UIButton) {
        textfield.text="you just clicked on button1"
    }
    @IBAction func action2(_ sender: UIButton) {
        textfield.text="you just clicked on button2"
    }
}

It is supposed to be all right. However, an error appears which shows:

thread1:signal SIGABRT

in file AppDelegate.swift line:

class AppDelegate: UIResponder, UIApplicationDelegate

What is wrong with my code?

like image 560
chucklai Avatar asked Apr 21 '17 15:04

chucklai


People also ask

How do you solve a SIGABRT error?

For example, an exception breakpoint will get triggered by an Unsatisfied constraints exception, but that won't crash your app. Use the exception breakpoint to gather extra information for the SIGABRT crash, and then disable it once you've solved the bug (until it's needed again).

What is signal SIGABRT?

The SIGABRT signal specifically indicates that your app called the "abort()" function, which is how apps crash themselves intentionally. The key to understanding a SIGABRT, therefore, is the error message displayed as part of the abort. In your case, you show this message in your second linked image.

What is a SIGABRT error?

A SIGABRT (signal abort) error means that the app was deliberately crashed due to some really bad problem, like a runtime error during the start-up sequence or a bad or unreadable user interface file.

What is abort signal from abort 3 SIGABRT error?

If an error itself is detected by the program then this signal is generated using call to abort(). This signal is also used by standard library to report an internal error. assert() function in c++ also uses abort() to generate this signal.


2 Answers

You get a SIGABRT error whenever you have a disconnected outlet. Click on your view controller in the storyboard and go to connections in the side panel (the arrow symbol). See if you have an extra outlet there, a duplicate, or an extra one that's not connected. If it's not that then maybe you haven't connected your outlets to your code correctly.

Just remember that SIGABRT happens when you are trying to call an outlet (button, view, textfield, etc) that isn't there.

like image 127
Andy Lebowitz Avatar answered Oct 12 '22 04:10

Andy Lebowitz


For me it wasn't an outlet. I solved the problem by going to the error And reading what it said. (Also Noob..)

This was the error:

enter image description here

And The solution was here: enter image description here

Just scroll up in the output and the error will be revealed.

like image 36
dangalg Avatar answered Oct 12 '22 03:10

dangalg