50

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?

saurabh
  • 6,687
  • 7
  • 42
  • 63
chucklai
  • 814
  • 2
  • 10
  • 26
  • 3
    You didn't properly connect your outlets. – rmaddy Apr 21 '17 at 15:29
  • I tried but failed to solve it. what do u mean by properly? for the code. how it is possible to identify two different buttons with the same code? – chucklai Apr 21 '17 at 15:41
  • 3
    did you connected the outlet to a button and then changed the outlet name by any chance? – Jose Quintero Apr 21 '17 at 18:38
  • 1
    a UIView object may still have an old connection too. Maybe try going through each of them by Ctrl+Click to bring up their connections or look at the Connections panel to the right. Double check theyre only connected where necessary – shearos Apr 22 '17 at 01:51

15 Answers15

81

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.

Andy Lebowitz
  • 1,471
  • 2
  • 16
  • 23
  • thanks for your help. I fixed the problem by recreate a new button item which means the outlet was wrong before. it there any way to view all outlet connections? – chucklai Apr 22 '17 at 06:55
  • 1
    Yep! Go to your storyboard, find the view controller of which you want to view all the outlets of, and click on the yellow logo at the top of it which shows a square inside a circle. Then go to the side panel on the right, and click the arrow with the circle (top right). There you can see all the outlet and action connections. – Andy Lebowitz Apr 22 '17 at 19:39
  • Got this when I made an IBOutlet when I meant to make an IBAction, and thought I removed the outlet (I didn't) – Robert Dundon Apr 02 '18 at 20:50
  • 1
    @RobertDundon make sure u remove the outlet in the code, AND in the storyboard connections tab, or you will get an error – Andy Lebowitz Apr 13 '18 at 15:12
  • I have this problem with tests, and it seems nothing to do with storyboards/appdelegates – Zaporozhchenko Oleksandr Jan 15 '19 at 09:29
  • @ZaporozhchenkoAleksandr hmmm is there a message in your error log? It could be that you’re in some way using a variable that isn’t initiated yet...what’s the log say? – Andy Lebowitz Jan 17 '19 at 11:57
  • @AndyLebowitz it says nothing, thats the problem. But i fixed it already, thx. However, i dont remember what was the problem, can't share :( – Zaporozhchenko Oleksandr Jan 17 '19 at 16:29
39

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.

dangalg
  • 6,398
  • 4
  • 27
  • 37
  • 1
    Note, also check the spelling in the code. When you call `dequeueReusableCell(withIdentifier: "cellIdentifier", for: indexPath)`, if the `withIdentifier` parameter is not the same as the `Identifier` property; then, this error will be thrown. – Tyler Apr 05 '18 at 13:21
35

To solve the problem, first clean the project and then rebuild.

To clean the project, go to MenuBar: Product -> Clean

Then to rebuild the project, just click the Run button as usual.

donjuedo
  • 2,475
  • 18
  • 28
Marwan Salim
  • 682
  • 7
  • 14
10

A common reason for this type of error is that you might have changed the name of your IBOutlet or IBAction you can simply check this by going to source code.

Click on the main.storyboard and then select open as and then select source code enter image description here

source code will open

and then check whether there is the name of the iboutlet or ibaction that you have changed , if there is then select the part and delete it and then again create iboutlet or ibaction. This should resolve your problem

Anshu Shahi
  • 151
  • 2
  • 4
8

In my case I wasn't getting error just the crash in the AppDelegate and I had to uncheck the next option: OS_ACTIVITY_MODE then I could get the real crash reason in my .xib file

enter image description here

Hope this can help you too :)

GOrozco58
  • 1,182
  • 12
  • 10
7

I had the same problem. I made a button in the storyboard and connected it to the ViewController, and then later on deleted the button. So the connection was still there, but the button was not, and so I got the same error as you.

To Fix:

Go to the connection inspector (the arrow in the top right corner, in your storyboard), and delete any unused connections.

Bijan Negari
  • 132
  • 2
  • 10
4

If you run into this in Xcode 10 you will have to clean before build. Or, switch to the legacy build system. File -> Workspace Settings... -> Build System: Legacy Build System.

Jon Vogel
  • 5,244
  • 1
  • 39
  • 54
3

This is a very common error and can happen for multiple reasons. The most common is when an IBOUTLET/IBACTION connected to a view controller in the storyboard is deleted from the swift file but not from the storyboard. If this is not the case, use the log in the bottom toolbar to find out what the error is and diagnose it. You can use breakpoints and debugging to aid you in finding the error.

To find out how to fix the error please use this article that I found on Google: https://rayaans.com/fixing-the-notorious-sigabrt-error-in-xcode

Rayaan Siddiqui
  • 345
  • 2
  • 9
2

In my case there was no log whatsoever.

My mistake was to push a view controller in a navigation stack that was already part of the navigation stack.

Xavier Lowmiller
  • 1,381
  • 1
  • 15
  • 24
2

Sometimes it also happens when the function need to be executed in main thread only, so you can fix it by assigning it to the main thread as follows :-

DispatchQueue.main.async{
  your code here
}
Bishnu Das
  • 161
  • 2
  • 14
2

For me, This error was because i had a prepare segue step that wasn't applicable to the segue that was being done.

long story:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        let gosetup = segue.destination as! Update
        gosetup.wherefrom = updatestring

    }

This was being done to all segue when it was only for one. So i create a boolean and placed the gosetup inside it.

JonesJr876
  • 39
  • 2
0

In my case, I was using RxSwift for performing search.

I had extensively kept using a shared instance of a particular class inside the onNext method, which probably made it inaccessible (Mutex).

Make sure that such instances are handled carefully only when absolutely necessary.

In my case, I made use of a couple of variables beforehand to safely (and sequentially) store the return values of the shared instance's methods, and reused them inside onNext block.

Revanth Kausikan
  • 673
  • 1
  • 9
  • 21
0

I had the same problem. In my case I just overwrote the file

GoogleService-Info.plist

on that path:

Platform\ios\YOUR_APP_NAME\Resources\Resources

In my case the files were present without data.

Abhinav Kinagi
  • 3,653
  • 2
  • 27
  • 43
Supriya
  • 481
  • 5
  • 5
0

If this crash occurs when accessing a view controller within a package you may have to remove the Class and Storyboard ID from the view controller within the package and then add them again, run the project and the view controller should be found

Adam Smith
  • 189
  • 1
  • 3
0

As for those who face this error while working on react native applications as I do:

I didn't recognize that my teammates already changed the minimum ios version from 12.4 to 13(you can see it on Podfile - platform :ios, '13.0'). And I was trying to run it on 12.4 that's why I got that error. To fix it:

  1. Open Xcode, click on top menu - Window,
  2. Select Devices and Simulators, Xcode will suggest to create a new simulator,
  3. Select OS Version: Download more simulator runtimes
  4. Xcode will open the Platform field where you can see all your existing OS versions.

Just create the right version for your app. That clean caches and run.

Ani
  • 68
  • 6