0

I'm new to xcode and this forum, so sorry for my unprofessional language.

I have a problem with the iOS simulator crashing when I'm trying to run an app. It does not always happen, when I've just started working on a project everything's fine. But then suddenly after I just change something minor in the code the iOS simulator crashes as soon as it starts (compiling works). Xcode then takes me to the debugging page and also shows a lot of output in the bottom-right-corner-window (which I don't know what it's called). I don't get anything of the output, it says something about NSencryption. Once the iOS simulator has started crashing it will crash every time it starts running that project/app. Even if I undo my changes I did when it stopped working and even if I erase all of my code and everything looks like a new project, IT JUST WON'T RUN.

Tried to call Apple support to solve this problem, but they said I should post a question in a forum, hope you can help me as I am really getting tired of this, I can't build anything.

Btw I've tried to reset the iOS simulator but the same problem continues to occur.

Here is the output I get from the 'console': Btw, please tell me if any of this code is sensible and I will remove it.

2015-03-26 17:39:52.727 Testing123[19815:4331412] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Testing123.ViewController 0x7f93ea8272c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key addFive.' *** First throw call stack: ( 0 CoreFoundation 0x00000001026e1a75 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000104239bb7 objc_exception_throw + 45 2 CoreFoundation 0x00000001026e16b9 -[NSException raise] + 9 3 Foundation 0x0000000102afcd43 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259 4 CoreFoundation 0x000000010262b5e0 -[NSArray makeObjectsPerformSelector:] + 224 5 UIKit 0x000000010323b4ed -[UINib instantiateWithOwner:options:] + 1506 6 UIKit 0x0000000103099a88 -[UIViewController _loadViewFromNibNamed:bundle:] + 242 7 UIKit 0x000000010309a078 -[UIViewController loadView] + 109 8 UIKit 0x000000010309a2e9 -[UIViewController loadViewIfRequired] + 75 9 UIKit 0x000000010309a77e -[UIViewController view] + 27 10 UIKit 0x0000000102fb9509 -[UIWindow addRootViewControllerViewIfPossible] + 58 11 UIKit 0x0000000102fb98a1 -[UIWindow _setHidden:forced:] + 247 12 UIKit 0x0000000102fc5f8c -[UIWindow makeKeyAndVisible] + 42 13 UIKit 0x0000000102f700c2 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2732 14 UIKit 0x0000000102f72e3e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349 15 UIKit 0x0000000102f71d35 -[UIApplication workspaceDidEndTransaction:] + 179 16 FrontBoardServices 0x0000000105deb243 __31-[FBSSerialQueue performAsync:]_block_invoke + 16 17 CoreFoundation 0x0000000102616c7c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 18 CoreFoundation 0x000000010260c9c5 __CFRunLoopDoBlocks + 341 19 CoreFoundation 0x000000010260c785 __CFRunLoopRun + 2389 20 CoreFoundation 0x000000010260bbc6 CFRunLoopRunSpecific + 470 21 UIKit 0x0000000102f717a2 -[UIApplication _run] + 413 22 UIKit 0x0000000102f74580 UIApplicationMain + 1282 23 Testing123 0x00000001025051ee top_level_code + 78 24 Testing123 0x000000010250522a main + 42 25 libdyld.dylib 0x0000000104a15145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

This is the code that gives me this error:

` import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}`

Here is the project

iEmil
  • 3
  • 2
  • 2
    Welcome to SO. If you want to get a helpful response you should post some relevant data, in your case that would be crash description from console (bottom right corner) and code that seems to cause the problem. – Jakub Vano Mar 26 '15 at 07:22
  • as @JakubVano says, please post your stack trace... otherwise it will be impossible for us to help you out with the issue :) – nburk Mar 26 '15 at 07:29
  • It sounds like your app is crashing (not the iOS Simulator). That window in the lower right is the debugger (lldb) window. Please post more details about the crash (eg: your code near the crash point, the backtrace of the crash, etc) to get more useful responses. – Jeremy Huddleston Sequoia Mar 26 '15 at 07:51
  • You have made an error in the code you changed and the program (app) is now crashing, this is not uncommon. It only takes a small change to create a crashing app. Examine what was changed and try to figure out what. Add the code in the area that you changed to the question as well as the Add the messages in the debugger window (the bottom right pane). Apple can not help you find an error in your programming, that is up to you but here is a good place to seek help. – zaph Mar 26 '15 at 11:37
  • Thanks for the quick replies! Just want to check with you guys if the error in the console could contain any sensible information I do not want someone to get a hold of before I upload the error? – iEmil Mar 26 '15 at 16:57

2 Answers2

0

You haven't given many details, but here's how to start resolving your problem.

The bottom of your Xcode app has a debugger window. In that window, messages from the app will display. When your app crashes, it will print out a stack trace which shows what happened just prior to the crash.

When posting here, you'll want to include that in your post. Within that crash log, the top portion will tell you what the problem was--typical issues are nil values or calling something outside a range. Looking further down in the crash log, you'll usually see system stuff (UIKit, etc.). Look at the most recent method called in the class YOU created. Then, find that method in your code and add a breakpoint next to it. The breakpoint will stop execution of your code when it gets to that spot. At the top of the debugger window in the bottom portion of your screen, you'll see a few buttons. One of them is "step over". When you hit your breakpoint, use the "step over" button to execute your code one line at a time. When you get to your problem, it'll crash.

You'll also want to Google the error the debug console spits out. 9 times out of 10, someone's encountered the issue you're encountering and you'll be able to proceed towards resolution of your problem. If that doesn't get the problem solved, you'll want to post here with details and the problematic methods.

Another thing I'd recommend doing is learning how to use GitHub. When I started learning this (and I still AM learning it), git seemed like overkill, but in hindsight it would have been a good idea to learn how to use git from the start. You'll be able to create branches to work on features in your software and merge them to a "master" when you've got new features working. When I was starting, I would get fairly far along, I'd make a minor change and I'd break a bunch of stuff--that will still happen with Git, but you'll have a version of the software that functions. Using Git, you'll be able to always have a stable version that works and you can add features without worrying about blowing up your entire project.

Good luck!

Update for new info:

Your starting point would be Googling this: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: ViewController setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key.

Also, the import UIKit should be #import UIKit. I suspect this post will steer you in the right direction.

What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"

Solution:

You have a ViewController.swift file, but your storyboard file is

1) incorrectly named and 2) doesn't have any scenes on it.

Here's what you need to do:

1) rename the storyboard file "Main.storyboard" 2) add a View Controller scene on storyboard, as you currently have no scenes on your storyboard. You do this by dragging & dropping View Controller from the lower right-hand portion of the screen. 3) When your ViewController scene is highlighted, at the top right-hand portion of your screen you should see some buttons. One of them is called "Attributes Inspector". Make sure "Is Initial View Controller" is checked. One button over to the left is "Identity Inspector". Make sure class is set to ViewController.

I'll say it again. If you want to learn iOS, I'd recommend learning GitHub first. Additionally, Stanford University has a free iOS course taught by a guy who worked closely with Steve Jobs which you'll probably find helpful. If it's "too much" starting out, I'd suggest picking up a Big Nerd Ranch book or looking at Ray Wenderlich's website.

Community
  • 1
  • 1
Adrian
  • 16,233
  • 18
  • 112
  • 180
  • 1
    Do not overlook using Git in Xcode from the Source Control menu, it is easy and works well. Then you can push to GitHub or BitBucket. – zaph Mar 26 '15 at 14:15
  • Thanks for the quick replies! Just want to check with you guys if the error in the console could contain any sensible information I do not want someone to get a hold of before I upload the error? – iEmil Mar 26 '15 at 16:56
  • probably not. depending upon what turns up in the log, it might have your username referenced somewhere. prior to posting, you might want to look it over. – Adrian Mar 26 '15 at 17:38
  • Yes, the error information is generally useful, add it to your question. Without any code and no error message it is impossible to help. – zaph Mar 26 '15 at 17:51
  • I just added the error information, hope it helps. Just tell me if you need something else! Thank you so much! – iEmil Mar 26 '15 at 18:17
  • Hi, thanks again for the quick reply. Sadly I did not understand a lot from that post, sorry for my incompetence. However I have a feeling that the problem lies locally on this mac (maybe because of a weird setting or something), and it would be very helpful if you (or someone else) could try to open and run the project on your mac to see if it works. https://drive.google.com/folder/d/0B6NqC1IBWuqrfkE2U1haUUtJN1VqZXpNM2NaTHdIR21JMU9DRDV4elIwVW1KcFE5SnhNU3M/edit – iEmil Mar 27 '15 at 08:59
  • I opened the file, found the error, and posted how to fix it here. – Adrian Mar 27 '15 at 11:50
0

The pertinent part of the error message is: "[<Testing123.ViewController 0x7f93ea8272c0> setValue:forUndefinedKey:]: this class is not key value coding-compliantfor the key addFive.'

Look for where you are using addFive. That is not defined for the instance yu are using it with.

zaph
  • 111,848
  • 21
  • 189
  • 228