Error in Lesson 16 QuestionBot 2

Apple developed Project files from Intro to App Development Lesson 16 on QuestionBot 2 are giving me errors as follows:

  1. The project will build and run fine. It will also answer the first question. However, asking a 2nd question causes an error of "Thread 1: signal SIGABRT". This is a file straight from the Apple Tutorial. Suggestions?
  2. Project files give warnings for depricated code are given as follows: "The use of Swift 3 @objc inference in Swift 4 mode is deprecated." Suggestions?

Thanks,

Mike

Replies

You should post the exact part of code where you get error.


Possibly, you may have a missing IBOutlet connection, or a corrupted one.


For point 2, that means that you have to declare explicitely @objc for functions that need it, typically functions used for selectors.


But, show code if you want precise help.

Thanks Claude31,


I wish I could include a screenshot. Below is the code for item #1. The error message is: "Thread 1: signal SIGABRT"


import UIKit

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

}


For item #2 it is a general warning and not next to any code. It says:

"The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "ChatBot" target."


I have not edited these files....they are straight from Apple. Any suggestions are welcome.

Mike

Problem 2 is the result of a change in Swift 4 (you can read SE-0160 Limiting @objc inference for the details). Fixing it is usually a two-step process:

  1. Run your app to make sure that the inference checker doesn’t notice any problems.

  2. Once you’re confident that things are working as expected, remove the Swift 3 @objc inference (

    SWIFT_SWIFT3_OBJC_INFERENCE
    ) build setting to disable the inference checker (and hence remove this warning)

If you’re just getting started then step 1 is going to be tricky, so I recommend that you just ignore this issue for the moment.

It’s hard to offer any input on problem 1 without knowing more about the problem. Ideally I’d like to see a backtrace of the problem. You can get this as follows:

  1. Run the program.

  2. When you crash into the debugger, switch to the Debug navigator (View > Navigators > Show Debug Navigator).

  3. On the left you’ll see a backtrace of the crashed thread.

  4. Select the relevant frames in that backtrace and copy them.

  5. Paste the result into a follow-up post here (make sure to use the

    <>
    button to format them as code).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Can you show the exact line at which you get the error 1 ? Otherwise, how do you want we guess ?


If this line references an IBOutlet, did you check the connections ?

Thank you for the prompt reply and excellent directions. I have copied below information from

  • the debug breakpoint,
  • the error message, and
  • below that all other debug information (just in case it helps).

I'm new to Xcode and appreciate your help.

Regards,

Mike


Debug Breakpoint

#12
0x000000010ee03fb7 in main at /Users/MacBells 1/Documents/AISB/Programming/Swift/01 App Development Curriculum/16_QuestionBot2/ChatBot/ChatBot/AppDelegate.swift:4


Error message on line 3 where class is declared says "Thread 1: signal SIGABRT"

import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
}


All information from Debug Navigator.

Thread 1 Queue : com.apple.main-thread (serial)
#0 0x00000001149d2e3e in __pthread_kill ()
#1 0x0000000114a0c150 in pthread_kill ()
#2 0x000000011468d0eb in abort ()
#3 0x000000011441f91f in abort_message ()
#4 0x000000011441fabb in default_terminate_handler() ()
#5 0x000000010f7291be in _objc_terminate() ()
#6 0x000000011443b159 in std::__terminate(void (*)()) ()
#7 0x000000011443ae0a in __cxa_rethrow ()
#8 0x000000010f7290dc in objc_exception_rethrow ()
#9 0x00000001133a2909 in CFRunLoopRunSpecific ()
#10 0x0000000115ba89c6 in GSEventRunModal ()
#11 0x000000010ffc55d6 in UIApplicationMain ()
#12 0x000000010ee03fb7 in main at /Users/MacBells 1/Documents/AISB/Programming/Swift/01 App Development Curriculum/16_QuestionBot2/ChatBot/ChatBot/AppDelegate.swift:4
#13 0x00000001145bad81 in start ()
Thread 5com.apple.uikit.eventfetch-thread (6)Thread 9

The crash you’re seeing (

SIGABRT
) is caused by some code within your process deliberately killing it by calling
abort
. This can happen for a variety of reasons but the backtrace indicates that in this case it was triggered by an unhandled language exception (frames 4 through 8). What you need to do now is figure out who threw that exception. You can do that by setting an exception breakpoint:
  1. Switch to the Breakpoints navigator.

  2. Press on the add (

    +
    ) button in the bottom left and then choose Exception Breakpoint from the menu.
  3. Run your program again.

  4. This time it shouldn’t crash, but rather stop at the exception breakpoint at the point that the exception is thrown. You can now look at that backtrace for hints as to what’s gone wrong.

If you can’t figure it out from the backtrace in step 4, post that backtrace here and we’ll take a look.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Problem Circumvented:

I re-downloaded the original project from Apple and discovered the problem as follows:

  • The project downloads with "Warnings" and recommendations to "migrate" the project to Swift 4. Therein lies the problem. After migration the problems arise. If you do NOT migrate, then there are no problems (yet the warnings remain).
  • The accompaning iBook lesson for this project is NOT correct in the last section labeled "Refinements". Adding "refinements" for "computed properties" does not work.

Whereas this is meant to be "Intro" lessons for Programming I would think that Apple would update their files more quickly so they can work with Xcode 9 and Swift 4. It's rather frustrating for young programmers to download Apple projects that contain so problems. Nonetheless, on the whole this iBook and Labs have been good.


Many thanks to those of you who took your valuable time to help.

Mike

  • Just a quick update, we're up to Xcode 13.1 and Swift 5, waiting on Swift 6 and the same errors are in the same code. Yay Apple!!!

Add a Comment