code-8
code-8

Reputation: 58672

Thread 1: signal SIGABRT AppDelegate.swift

I tried to compile my first iOS Hello app.

I have

ViewController.swift

//
//  ViewController.swift
//  My First Project

import UIKit

class ViewController: UIViewController {

    // Declare components
    @IBOutlet weak var inputLabel: UILabel!
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        
    }

    @IBAction func submitBtn(_ sender: Any) {
        inputLabel.text = "Hello World"
        
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

I Kept

getting Build Succeeded

enter image description here

But after about 5 seconds, I got this

enter image description here


Console Error

enter image description here

         0x0000000103915f69 -[UIApplication workspaceDidEndTransaction:] + 188
    18  FrontBoardServices                  0x000000010770f723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    19  FrontBoardServices                  0x000000010770f59c -[FBSSerialQueue _performNext] + 189
    20  FrontBoardServices                  0x000000010770f925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    21  CoreFoundation                      0x0000000105ff0311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    22  CoreFoundation                      0x0000000105fd559c __CFRunLoopDoSources0 + 556
    23  CoreFoundation                      0x0000000105fd4a86 __CFRunLoopRun + 918
    24  CoreFoundation                      0x0000000105fd4494 CFRunLoopRunSpecific + 420
    25  UIKit                               0x00000001039147e6 -[UIApplication _run] + 434
    26  UIKit                               0x000000010391a964 UIApplicationMain + 159
    27  My First Project                    0x0000000102e6db3f main + 111
    28  libdyld.dylib                       0x0000000106f7868d start + 1
    29  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Try #1

Connection Inspector

I used to have this

enter image description here

I updated to this

enter image description here

Re-run and still happening ...


Try #2

Clean project

Re-run and still happening ...

Upvotes: 13

Views: 12409

Answers (8)

Sti
Sti

Reputation: 8493

This happened to me because I was copying some files from another project (and renaming them). Xcode got confused and apparently struggled with connecting outlets. In Xcode everything looked fine, but I was stuck with the same error as in the question on runtime, with no further explanation.

I fixed it by cleaning the project and deleting derived data. As always.. :/

Upvotes: 0

Dhiru
Dhiru

Reputation: 3060

This problem happens when you delete referencing outlet in your ViewController and forget to remove the connection from storyboard.

Perfect connection ✅

The perfect referencing outlet looks like below screenshot.

enter image description here enter image description here

Now let's delete the referencing outlet from .h file

Problem ⚠️

if we remove referencing outlet from .h file Xcode will give warning in Storyboard. this is the trick you can find which outlet was deleted from the class.

i hope this will help you .

enter image description here

enter image description here

Solution

In your case you may have changed the name lable to inputLable so you need to do :

Remove the connection to label. Re-Connect the controller to inputLabel.

Upvotes: 6

vaibby
vaibby

Reputation: 1265

have u checked default IBOutlet of view.

enter image description here

Upvotes: 2

Maryam Fekri
Maryam Fekri

Reputation: 625

Others have mentioned about outlets and its references which you have to make sure about them that they have connected correctly in to your class.

Another possible case comes to my mind may be this : If you have define a key path for your label under user defined Rundtime Attributes in the identity inspector tab in storyboard, and if the key is undefined, you will get this message error in your console log :

...this class is not key-value compliant for the key label.

e.g. in the image below you see a key path popupTitle if it is not defined in your class of label it will get this error message. and in some cases it will crash. Make sure you don't have extra key path in this section.

enter image description here

Upvotes: 1

Raza.najam
Raza.najam

Reputation: 769

Issue is in your labels, I am 100% sure you have deleted some outlet references and forget to remove the connection from story board. Please check

Upvotes: 12

Jenny Tran
Jenny Tran

Reputation: 553

It crashed because you removed your IBOutlet label in your code of ViewController.swift without removing the connection on Storyboard.

@IBOutlet weak var label: UILabel!

To solve this problem, right click on inputLabel in storyboard, click the 'x' button at label connection like this: Remove removed connection

Note: Please don't forget remove the connection in storyboard before removing your IBOutlet in code.

Upvotes: 1

vadian
vadian

Reputation: 285082

There is an inconsistency in code and screenshot.

  • Code: label.text = "Hello World"
  • Screenshot: inputLabel.text = "Hello World"

The error message is :

... is not key-value compliant for the key label.

So most likely in your actual code the IBOutlet is named inputLabel but in Interface Builder there is a (dead) connection to label which causes the crash.

Solution:

  • Select Main.storyboard in the navigation bar and ViewController in the canvas.
  • Open the Connections Inspector (⌥⌘6)
  • Remove the connection to label.
  • Connect the controller to inputLabel.

Upvotes: 2

Marleen Berg
Marleen Berg

Reputation: 11

Make sure the storyboard elements are connected to the outlets in your code. Try to delete all the connections in the connections inspector and reconnect the elements

When you go to main.storyboard, on the right you have a panel, the most right one os the connections inspector. In there you have to delete al the connection by pressing the little 'x' in the connections.

It should look somewhat familiar like this, but different names in this screenshot

delete all of them

also in your viewController.swift file, remove all the @IBOutlet lines.

Then connect your outlets again to your ViewController.swift file, which you did before

For just changing a label in code it finally should look like this final screenshot

mind the outlet on the right

I hope this will help you!

Upvotes: 1

Related Questions