Can't run XCode templates - xcode

I'm new to iPhone development and have run in to a problem.
This is what I do;
Create a new project (any type, unchecking Use storyboards).
Running it.
This is the error I get;
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<UIApplication 0x6a35470> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key view.'
I haven't added any code at all yet, so this suprises me a bit.
Should I not be able to run an 'empty' app?
When I use storyboards I can run the project, add all the objects and code I want and run it just fine.
It just feels like I'm missing something really simple.
Thanks in advance!

Yes, you're missing something really simple.
Select your project on top left, select your target and check where it says:
Main Storyboard:
Main Interface:
You have to have a window to start up with....

Related

Why is my app crashing - 'NSUnknownKeyException'?

Im having an issue with Xcode where its crashing on references to old variables which I have deleted, the error message is
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<mydoncaster.OptionsView 0x11fd94eb0> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key restaurantLabel.'
I don't know why its moaning about restaurantLabel when that no longer exist in the specific view controller, I can delete everything out of the view controller and from the storyboard and build it all again and it still brings up the error, I've also tried building and cleaning my code but it still happens, is this a saving issue or something else.
Search for "restaurantLabel" in your storyboard.
There should be an outlet somewhere in "Referencing outlets" section, which you've forgotten to delete.

How to avoid this error: "Took too long to show custom notification. Falling back to static."?

Having issues testing out the custom long look notification on the apple watch simulator. The debugger log this error:
WatchKit Extension[5230:156324] Took too long to show custom notification. Falling back to static.
How to resolve this issue?
I had exactly this problem with the default code set up by Xcode. I didn't do any operations inside didReceiveRemoteNotification, but the error still occured.
Turns out the reason it failed was that my WKUserNotificationInterfaceController subclass was not connected to the Dynamic interface Controller in my storyboard file.
Solution:
Go to the storyboard file for your watchkit app.
Click on your Dynamic Interface controller
Click the identity inspector (middle tab in the right pane)
In the Class field, select your
WKUserNotificationInterfaceController subclass (xcode had named mine
NotificationController)
VoilĂ !
I had the same issue before.
Inside didReceiveRemoteNotification, are you calling completionHandler(WKUserNotificationInterfaceTypeCustom); ?
Also, what are you doing inside that function? If takes too much time, it will show by default the static notification:
"Use the static notification interface to define a simple version of
your custom notification interface. The purpose of a static interface
is to provide a fallback interface in the event that your WatchKit
extension is unable to configure the dynamic interface in a timely
manner"
Try giving your custom class name as NotificationController. Xcode take it as WKUserNotificationcontroller. It worked for me.
This will happen if you take too long in your handler to setup. If it takes too long, the watch will default to the static notification.
Be sure you are calling the correct completion block:
completionHandler(WKUserNotificationInterfaceTypeCustom);
When calling the completion handler block, if you want WatchKit to display your static interface instead, specify the WKUserNotificationInterfaceTypeDefault constant.
Reference:
https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/CustomzingthePushNotificationInterface.html
In my case the problem was that the created WatchKit Extension was configured as Swift code, while my entire project was in Objective-C.
The Dynamic Interface never show up, always switching to the Static one printing the error of this post in the console. Once I changed the WatchKit Extension to Objective-C everything worked perfectly.
If you use a real watch, try turn off "Wrist Detection" in "Watch" -> "General".

'Could not instantiate class named NSLayoutConstraint' while auto layout is disabled

My application is crashing on iOS 5 when I call presentModalViewController on a new view with the error:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
I know that this error should be fixed by unchecking auto layout, but it isn't. I unchecked it in all my nibs.
The very puzzling part is that using a view I created one month ago, there is no crash, but using one that I created today, it crashes.
Is there another setting that I should know about?
I'm using XCode 4.5.2, with SDK 6.0, and deployment target 5.0.
I guess you would have solved the problem by now.
But for others who would stumble into this post, please check this post: https://stackoverflow.com/a/13201690/942966

Interface Builder XIB Compiler error

I get this error message when connecting two UISwipeGestureRecognizers to a single view in my project inside of a XIB file (though not in a new project, curiously). Anybody know what this error means? It is a compile error, not a runtime error. I'm using Xcode 4.4 (this error doesn't happen on Xcode 4.5 actually). This is an error from inside interface builder.
Assertion failure in -[IBCocoaTouchToolObjectPackage connectionsByProcessingConnections:], /SourceCache/IBSimulatorComponents/IBSimulatorComponents-223/IBCocoaTouchTool/IBCocoaTouchToolObjectPackage.m:1132012-08-03 16:52:01.428 Interface Builder Cocoa Touch Tool[5646:11903] Exception producing nib: Mismatched addsContentToExistingCollection value for the coalescing outlet connection & one of its fragments.
I suspect this occurs because Interface Builder allows your outlets to get into an inconsistent state. It's a logic bug in Interface Builder that manifests as a run-time exception in the ibtool compiler. I was able to work around it by disconnecting the outlets and outlet collections I had recently created, and then rewiring them.
I was actually able to get rid of the error by deleting the entire Panel in the XIB, and then just undoing the delete. Clean + Build and the error was gone. Not sure if that will work for others as well.

Error: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x6887a30> setValue:forUndefinedKey:]

The full error is: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key.
So I have been trying what other people have been saying with similar problems. I have tried getting rid of every mention of landscapeView in the project, including the Connections in the FIle's Owner in the ViewController_iPhone.xib and then I started fresh by making outlets in the super class ViewController (since I want to use landscapeView and portraitView for iPad also) then I set up connections in ViewController_iPhone.xib and ViewController_iPad.xib to the UIView named Landscape in each respectively, and I still get this error.
I'm just starting out in app development so I'm trying to make a template for an app that is supportive of all orientations on both iPhone and iPad. Thanks for any help
EDIT: Here is a link to all my app delegate h and m and main.m : I am getting the Applications are expected to have a root view controller at the end of application launch error
EDIT 2: So I also tried to make landscapeView a property of ViewController and I made a setter method in ViewController.m but it still has the same problem.
I've found the most common place this error happens is when you instantiate a view from a xib from within a class that is not the xib's owner.
What I mean by this is you might be calling something similar to this:
[[NSBundle mainBundle] loadNibNamed:#"MyView" owner:self options:nil];
You're changing the owner, so you have to be sure that the class that self refers to has all the IBOutlet properties needed by "MyView". Usually this is done in Interface Builder, but in this case you're setting your owner programmatically, which means you can't make the connections in IB. When the IBOutlets aren't there, the app tries to make those connections and fails, giving the error you see.
My advice (without knowing any more info than you've given so far) is to check to see if you've made this call without having the proper IBOutlets.
I had to remove the NIB or XIB (or whatever they are this iteration) for the Main Interface.
It sure would be nice if Apple fully tested the broken software before unleashing it on the unsuspecting public. They could have handled the problem in any number of ways; but instead they chose a runtime crash and obscure [meaningless] error message.
Two main reason is follow
your iboutlet may break please check in storyboard or IB.
if you don't select module for custom class, see into your storyboard.
What I found is I deleted a WebView in viewcontroller.h , but haven't delete the xib file that point to this WebView !

Resources