Thread 1: signal SIGABRT

Hello,


I'm having an issue with my single view app. The build is succeeded but the excution fails. Here is the main code -- ViewController.swift --:


//
//  ViewController.swift
//  Décodeur
//
//  Created by Boustani on 9/23/19.
//  Copyright © 2019 Stif. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var champMessageCodé: UITextField!
    
    @IBOutlet weak var libelléMessageDécodé: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        mettreÀJourMessageDécodé()
        champMessageCodé.becomeFirstResponder()
    }
    
    @IBAction func champTexteAChangé(_ sender: Any) {
        mettreÀJourMessageDécodé()
    }
    private static func décoder(message messageCodé: String) -> String {
        return String(messageCodé.reversed())
    }
    func mettreÀJourMessageDécodé() {
        let texteEntré = champMessageCodé.text ?? ""
        let messageDécodé = ViewController.décoder(message:texteEntré)
        libelléMessageDécodé.text = messageDécodé
    }
    
    

}


And here is my stacktrace:

2019-09-29 22:05:36.999631+0100 Décodeur[32109:3024886] Unknown class _TtC9Décodeur14ViewController in Interface Builder file.

2019-09-29 22:05:37.214381+0100 Décodeur[32109:3024886] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7ff368f07be0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key champMessageCodé.'

*** First throw call stack:

(

0 CoreFoundation 0x00000001093bf8db __exceptionPreprocess + 331

1 libobjc.A.dylib 0x00000001079d6ac5 objc_exception_throw + 48

2 CoreFoundation 0x00000001093bf449 -[NSException raise] + 9

3 Foundation 0x000000010744b3a6 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 289

4 UIKitCore 0x000000010bb11f8e -[UIViewController setValue:forKey:] + 87

5 UIKitCore 0x000000010bd9fcd9 -[UIRuntimeOutletConnection connect] + 109

6 CoreFoundation 0x00000001093abf21 -[NSArray makeObjectsPerformSelector:] + 305

7 UIKitCore 0x000000010bd9ca1f -[UINib instantiateWithOwner:options:] + 1810

8 UIKitCore 0x000000010bb1906b -[UIViewController _loadViewFromNibNamed:bundle:] + 382

9 UIKitCore 0x000000010bb199f5 -[UIViewController loadView] + 177

10 UIKitCore 0x000000010bb19d04 -[UIViewController loadViewIfRequired] + 172

11 UIKitCore 0x000000010bb1a524 -[UIViewController view] + 27

12 UIKitCore 0x000000010c15322b -[UIWindow addRootViewControllerViewIfPossible] + 122

13 UIKitCore 0x000000010c15391f -[UIWindow _setHidden:forced:] + 289

14 UIKitCore 0x000000010c16657e -[UIWindow makeKeyAndVisible] + 42

15 UIKitCore 0x000000010c11633c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4555

16 UIKitCore 0x000000010c11b4e6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1617

17 UIKitCore 0x000000010b95fa4e __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 904

18 UIKitCore 0x000000010b968346 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153

19 UIKitCore 0x000000010b95f664 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236

20 UIKitCore 0x000000010b95ffc0 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1091

21 UIKitCore 0x000000010b95e332 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 782

22 UIKitCore 0x000000010b95dfe9 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 433

23 UIKitCore 0x000000010b962d2e __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 576

24 UIKitCore 0x000000010b963988 _performActionsWithDelayForTransitionContext + 100

25 UIKitCore 0x000000010b962a95 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 223

26 UIKitCore 0x000000010b967a48 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392

27 UIKitCore 0x000000010c119dc8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 514

28 UIKitCore 0x000000010bcd102f -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361

29 FrontBoardServices 0x00000001145fcd25 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448

30 FrontBoardServices 0x0000000114606ad6 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 283

31 FrontBoardServices 0x0000000114606300 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53

32 libdispatch.dylib 0x000000010a757db5 _dispatch_client_callout + 8

33 libdispatch.dylib 0x000000010a75b2ba _dispatch_block_invoke_direct + 300

34 FrontBoardServices 0x00000001146380da __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30

35 FrontBoardServices 0x0000000114637d92 -[FBSSerialQueue _performNext] + 451

36 FrontBoardServices 0x0000000114638327 -[FBSSerialQueue _performNextFromRunLoopSource] + 42

37 CoreFoundation 0x0000000109326db1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17

38 CoreFoundation 0x0000000109326633 __CFRunLoopDoSources0 + 243

39 CoreFoundation 0x0000000109320cef __CFRunLoopRun + 1231

40 CoreFoundation 0x00000001093204d2 CFRunLoopRunSpecific + 626

41 GraphicsServices 0x00000001115582fe GSEventRunModal + 65

42 UIKitCore 0x000000010c11cfc2 UIApplicationMain + 140

43 DeÃÅcodeur 0x00000001070f58eb main + 75

44 libdyld.dylib 0x000000010a7cc541 start + 1

45 ??? 0x0000000000000001 0x0 + 1

)

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

(lldb)

Replies

Take a close read of the error message here:

UIViewController
… is not key value coding-compliant for the key
champMessageCodé

Note that it says

UIViewController
, not
ViewController
. For some reason, the nib doesn’t know about your
ViewController
subclass. You should be able to fix that in the Identity inspector.

Share and Enjoy

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

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

I have this same problem, but for me it only occurs when I run on an iOS 12 phone, compiling using XCode 11.2
If I run on an iOS 13 phone it's all good.
On iOS12 I get:

2019-12-02 14:31:41.680401+1300 CCP.iOS[608:60415] Unknown class _TtC7CCP_iOS29BluetoothActionViewController in Interface Builder file.

2019-12-02 14:31:41.696401+1300 CCP.iOS[608:60415] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x1021777d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _actionView.'


Note: My ViewController is called BluetoothActionViewController, and it has an outlet


@IBOutlet weak var _actionView: UIView!


I don't think my storyboard is wrong because it does compile and run correctly all on an iOS 13 phone.
Is there some workaround to enable this to work on iOS 12? I hope so

The first message you get:

2019-12-02 14:31:41.680401+1300 CCP.iOS[608:60415] Unknown class _TtC7CCP_iOS29BluetoothActionViewController in Interface Builder file.

confirms that the IB file is referencing your

BluetoothActionViewController
class, but somehow that class isn’t being found at runtime. I suspect that the runtime is falling back to using an instance of the parent class,
UIViewController
, which explains the second message.

As to why it’s not finding

BluetoothActionViewController
on iOS 12, I can’t think of any obvious reason for that. If I demangle the name:
$ swift demangle _TtC7CCP_iOS29BluetoothActionViewController
_TtC7CCP_iOS29BluetoothActionViewController ---> CCP_iOS.BluetoothActionViewController

I see that the class is meant to be in the

CCP_iOS
module. Is that the name of your app? Or a framework within your app?

Oh, and exactly what build of iOS 12 are you testing this on? iOS 12.0? Or iOS 12.4.x? This matters because iOS 12.2 has an embedded Swift runtime.

Share and Enjoy

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

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

Exact same issue I am facing. Works fine on iOS 13, getting the same errors on iOS 12.x


2019-12-10 11:51:54.379859+0530 SampleApp[860:373730] Unknown class _TtC9SampleApp11OrderPageVC in Interface Builder file.

2019-12-10 11:51:54.477752+0530 SampleApp[860:373730] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x13be59400> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key amountTextField.'

Same problem for me. App has been building just fine for many, many months. Today it's suddenly getting the above error when building for a couple of iOS 12 devices (12.3.1, 12.4), but not for an iOS 13 device. Happening on both Xcode 11.3 and earlier versions.


No obvious recent changes to the storyboard, nor to the relevant view controller class.


I've tried several of the many fixes that have been reported on StackOverflow over the past several years, so far without success.

Can you reproduce this with a small test project that you create from scratch? If so, please post the instructions for how you did that.

If not, please try cutting down your main project to the absolute minimum (it should just be a storyboard with a single view controller), post the project somewhere, and then post a link here (that’ll require moderation, but that shouldn’t be a problem).

Share and Enjoy

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

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

I've taken this over from Dave Goldman PDX. This is due to enabling BUILD_LIBRARY_FOR_DISTRIBUTION in a dependent cocoapod that we are developing. Unfortunately I cannot seem to resolve the issue. The behavior is that public structs in the cocoapod are causing this error when declared as class properties. The baffling part is that using that symbol any other way seems to work, i.e. in another class or in a later function like viewDidLoad. So


class ViewController: UIViewController {

     @IBOutlet weak var button: UIButton!

     var myStruct: PodStruct?

     ...
}


Doesn't work.


But declaring a new class Test does:

class Test {
     var myStruct: PodStruct?
}

class ViewController: UIViewController {

@IBOutlet weak var button: UIButton!

var test = Test()

...
}


And also using the symbol later also works:

class ViewController: UIViewController {

     @IBOutlet weak var button: UIButton!     

     override func viewDidLoad() {
          super.viewDidLoad()
          var myStruct: PodStruct?
     } 

     ...
}


Changing the struct to a class also works. I thought it might be related to the known issue in Xcode 11.2 release notes about how module and type names can't be the same, but even after changing the type name we still have this issue. Any insight into what may be going on would be greatly appreciated.

Have you tried setting up a small test project that reproduces this? Well, two projects, one of the library and one for the app that uses the library.

Share and Enjoy

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

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

I have. I've created a repo with both projects here: https://github.com/zach-babb-streem/build-library-for-distribution-bug-reproducer . The build fails on iOS simulators and devices running iOS 12.x, and works on those running iOS 13. I've verified the behavior in my last post with these small projects.

I submitted a reply yesterday with a link to my repo where I've reproduced this with a small project and framework. That post is still under moderation so I figured I'd post a reply to let you know I've not left you hanging.

I notice you project is still dependent on CocoaPods. What happens if you remove that from the equation?

Share and Enjoy

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

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

ps DTS is closed 21 Dec through 1 Jan.

Removing Cocoapods still crashes. But! Adding `@frozen` to the struct makes it not crash. https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID620

Removing Cocoapods still crashes.

Cool. Well, not cool, but at least you have a standalone project that reproduces the problem. My advice is to take that project and use it to file a bug. I’m not sure what’s going on, but I think you’ve isolated enough to justify someone from the Swift team looking at it.

Please post your bug number, just for the record.

Adding

@frozen
to the struct makes it not crash.

Interesting. Make sure to include that tidbit in your bug report.

Share and Enjoy

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

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

ps DTS is closed 21 Dec through 1 Jan.

An honest to goodness bug. That's pretty cool. Here's the link to the bug: https://bugs.swift.org/browse/SR-11969. Thanks for taking a look!

One year later and the problem is still there. @ Lazer+PDX thanks a million !!! for that "frozen" fix/workaround.

  • I've the same problem, ios 12.5.1

Add a Comment