I am hoping that someone else has run into this problem before.
In an Xcode Cocoa Application project I create a *.xib file with a single view, and some random sub views. I create a *ViewController.m and inherit from NSViewController. I set the file owner in the *.xib to my controller and set the outlet view to the main view. I then create a new controller instance in the AppDelegate's applicationDidFinishLaunching: and add its view as a child to self.window.contentView.
Here is the weird part... this works JUST fine in a fresh Xcode Cocoa project. The view from the *.xib is added to the main window as expected. However in the project I am currently working on I get [NSViewController loadView] loaded the "(null)" nib but no view was set no matter what I do. At one point in time this worked in this project, it now errors every time. I have even reverted the entire repo from an old Git commit! I assume i'm seeing an Xcode bug?
EDIT More info:
This seems to be connected to having the project as a child of another Xcode project. If I open the project individually (Rather than the parent project) it runs as expected.
I had a similar problem: I wrote a ViewController then added a xib and changed the File's Owner there. Then I added a ViewController object in my MainMenu.xib and changed the Custom Class of this object to my ViewController.
What I forgot and what caused the same exception: In the MainMenu.xib I had to click on the ViewController object and in the Attributes Inspector I needed to specify the Nib Name which should be loaded when the ViewController gets created. Sadly Xcode needed a restart for getting my changes.
Anyway, I hope this helps everyone who checked every view connection twice but still got the exception.
Although not an explanation of why it was happening, I found out how to fix this. I changed the entire project over to a workspace and my runtime error vanished. Originally it was a parent project, with 2 children projects.
Well knowing well that this code SHOULD work.
I did a simple experiment.
I simply recreated the xib for that particular item and the issue went away.
So IMHO this is a bug from apple.
I sure have a long list of them piling up here and there.
...
This whole thing started after i noticed very slow performance on the NSCollectionView, originally i had the cells into their own nib, but it appears this is not needed anymore, since you can define the custom NSCollectionViewItem in the same xib as the NSCollectionView.
Cocoa will then call a copyWithZone: and will be fine.
I guess my fault for not having adapted to some of the new patters from Apple.
Related
I have read several other posts on SO about this and all say there is an issue with my view not being set on the File Owner. This makes sense, however my view IS set as well as all of my other connections in the XIB and I keep getting this error.
I tried using the loadView approach instead of viewDidLoad approach and it loaded just fine, however it is a "widget-intensive" app so I'd prefer to use a xib if possible.
It was working earlier, but then I made some massive changes. However as it is just a simple app for fun, I wasn't bothering with source control so I can't go back now.
Any idea how to debug this kind of problem or where to start looking?
Cheers
You have a very specific error message so it should not be too hard to debug.
Make sure you are looking at the correct XIB -> try deleting the XIB and see if it complains that the file dosnt't exist.
Check the class type of the files owner. It must match the ViewController you are tying to initiate. If it doesn't, set it correctly.
Check the view outlet dons't have a yellow warning next to it. If so delete the outlet and remake it.
Check the line of code you are initing the view controller with. Check it has the correct class and nib name.
Check that the XIB is included in the target.
This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 7 years ago.
Hi I seem to have stumbled upon weird thing while developing a storyboard app.
My app is halted right after splash screen and in console I get error message:
Missing proxy for identifier UIStoryboardPlaceholder
Now, if I try to let the app continue running, I get new messages into console, which I believe are related to the fact, that there is something wrong with the first error message
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<IntroViewController 0x6e35f40> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key sceneViewController.
What is strange I get this error only when working with iOs 5.1 Simulator. It works fine on iOs 6 simulator and also on devices with both iOs 6 and iOs 5.1
I tried to find answer, but google says it could not find any results for the word UIStoryboardPlaceholder, let alone the whole error message. I made sure, I don't have the word 'UIStoryboardPlaceholder' anywhere within my xcode project(not even inside nib files) and also there's nowhere mentioned 'sceneViewController'. Any idea what might be wrong?
EDIT: I tried to reset simulator and cleaning project, but to no avail
We had the same problem: a view controller in a storyboard file with its interface defined in a separate XIB file. (Using Xcode 6.3.1, iOS 8.3 and Swift 1.2.)
We are using Swift so we had added the #objc() declaration to the class declaration:
#objc(TestViewController) class TestViewController: UIViewController
We could instantiate the view controller just fine from another view controller using self.storyboard?.instantiateViewControllerWithIdentifier( "TestViewController" ) but when presenting the view controller (using self.presentViewController( viewController, animated: true, completion: nil )) the app crashed with the same "missing proxy" and "not key value coding-compliant for the key sceneViewController" error.
Our solution which we found after much frustrated trial-and-error-like debugging was simply make sure the view controller's Storyboard ID in the storyboard file is not the same as the class name.
When we renamed the Storyboard ID from "TestViewController" to "testViewController" (only difference being the lower-case first letter), everything worked…
Strange? You betcha, but everything seems to be working now.
I had the same problem. Try cleaning the project and restoring the simulator.
I was getting the same error with an app that I was converting from .xib files to storyboards. My app contained a UITabBarController, and tapping on certain tabs would trigger the error.
In my case, the problem was that I had copied view controllers into the storyboard that used the "NIB name" property to load the view controller's view from an external .xib file. Storyboard view controllers do not support loading views from .xib files, so my storyboard contained a view controller that had no view.
I opened the external .xib file, copied the view, pasted it into the corresponding view controller in my storyboard, and made sure that the pasted view was subordinate (indented under) the view controller in the storyboard scene. Then I re-connected the view to the outlets in the view controller.
When I re-ran the application, the error was gone.
Add me to the list. I get this error after "refactoring - rename" on a class. The class I am renaming is a custom ViewController with its own .xib. I use Storyboard which launches a viewController containing a "Container View", which has my custom ViewController embedded in it upon launch.
The only way out of this so far is to NOT use my refactored .xib (disconnect it from the container view).
My semi-solution:
I have restored my app from a prior working snapshot and created a new custom ViewController and .xib from scratch instead of refactoring. Connected it to Storyboard and I got the error message again. Cleaned the build and deleted the app from the simulator and re-ran, and then it magically ran without error. For this reason I believe there is a bug in Xcode with Refactor-Rename, which corrupts some storyboard file behind-the-scenes. Once I confirmed that the new .xib was attaching to storyboard without error, I copied/pasted the class code into the new custom viewController class, and went through the process of reconnecting the class objects to the .xib, as you'd expect. Ran it and everything still worked.
FYI - here are some of the FAILED steps I took in my attempt to recover from the error (before giving up and restoring snapshot).
1. Cleaning Build.
2. Deleting App in iOS simulator.
3. Deleting all views in the custom ViewController .xib.
4. Naming the custom ViewController something else.
5. In Storyboard, adding a blank view to the ViewController representing my custom Viewcontroller class. This worked and allowed my app to run, however my custom class was neither able to load its own views in place of this default blank view, nor were it's own views visible upon making the default blank view transparent. Debugging showed my custom class .xib views being nil when assigned to self.view.
I am presently avoiding Xcode's Refactor-Rename for files having a .xib.
I had the same errors, finally solved it.
My problem was that I had :
[[storyboard instantiateViewControllerWithIdentifier:#"TripDetail"] methodThatDoesNotExist:#"param"]
I'm playing arround with Xcode (for iOS) and added a View Controller to my Storyboard. Now I've created a Class (File -> New File -> Objective-c Class) and made that a subclass of UIViewController. Now the .h and .m files are generated and listed on the left side in Xcode, but when I want to change the "custom class" of my added View Controller there is nowhere my class which I had generated. Am I doing something wrong?
Thanks in advance.
I've had the same problem. Quitting and opening Xcode will make the Class show up in the list.
edit: I've also recently found pasting the Class name will work in 5.02 Xcode.
I had the same problem. But I discovered that I was clicking inside the "window of storyboard" and was selecting a view, so with no viewController related to. My solution was: to click inside the owner, or the viewController from the left list, and then change the custom class.
There are multiple reasons and solutions....
#1
Select project icon in "Project Navigator".
Then go to your Target's Build Phases -> Compile Sources.
Finlly, click the + button, and add your *.m or *.swift file.
#2
In one case, the same file was added multiple times to project:
Remove all instance of the file.
Add file back to project (once).
Finally, select the file in "Project Navigator", and in the "File inspector" on the right, look at the "Target Membership" section. The app target (not the Test target) should be checked, similar to this:
#3
ANOTHER WAY IS
Save all my work;
Just quit Xcode & load it again;
Then I was able to insert the new outlet connection successfully.
#4
Close the project you are working on with.
Delete the【DerivedData】folder of you project.
Said folder may be:
Inside your project's folder,
Or, inside ~/Library/Developer/XCode/DerivedData/(your project)/
Or, somewhere else that was setup by you.
Restart you project.
#5
Simply Clean your Project,
Then Build Again,
Finally, check and/or run.
I'm not sure what you mean by " but when I want to change the "custom class" of my added View Controller there is nowhere my class which I had generated ". It seems like you are trying to make the UIViewController in your storyboard to be of the same type of your custom UIViewController subclass.
If that's the case, then select your UIViewController (make sure you're not selecting the UIView within that UIViewController)
With the UIViewController selected, open the right hand view and open the Custom Class tab, then start typing in the name of your UIViewController subclass.
If that isn't working, then you need to ensure that the in the .h file you say:
#interface MyCustomUIViewController : UIViewController
If it still isn't working, ensure that in storyboard you are selecting the UIViewController that you put down. If you are trying to fill in the Custom Class of a UIView with a UIViewController subclass, it shall not work!
If it all still doesn't work, try COMMAND+SHIFT+K, and COMMAND+B to Clean and Build!
Good luck.
Just a quick advice in case you are about to give up: Do check that the item you have in the storyboard is compatible with the custom class you created that you are trying to assign. For example, you cant choose a UIView based class if you have a UIImageView as a component in your storyboard. In that case, it simply wont appear in the dropdown list.
You don't have to completely quit Xcode. Just close all your Storyboard tabs completely and reopen a new tab by double clicking on it.
Solution for my situation - just close all other xCode windows (i got opened few projects at same time).
Also sometimes help cleaning of project.
I am working on an Iphone Application, and I want to get a storyboard from another project.
I added the storyboard and all the viewcontrollers and images to my project (I copy Paste them from the other project)
Then I set it as the main storyboard in the info,plist file.
I get no compile errors or warnings however if I try to run the project I get a signal SIGABRT error.
(If i return to my original storyboard the app runs normally)
Any idea what might be causing the problem?
Thanks a lot for any help
Have you wired all storyboard object to proper ViewController ?
I often forget wiring delegate =)
In the summary tab make sure that the main storyboard is selected under "project name"/summery/ iPhone/iPod deployment info
I am building an iOS app and i have most of the code/GUI built (its a single view app). Now i have the .xib and controller.h file next to each other and I want to associate a button click with a certain action. Everytime I try nothing happens. The UI indictor that I am dragging shows up but it wont let me connect to the method. This happens for all the objects/methods.
I have an almost identical project that works just fine too!
Select your XIB file and then select "Files Owner" which is the yellow cube.
In the Utilities Sidebar, select the Icon with the circle and arrow inside of it (which is the "Connections Inspector").
You can then Control + Drag your to your button.
//// Edit ////
After investigating your project...
Pretty sure you deleted a storyboard and then added a .xib but didn't set it's class, or link it's view as an outlet.
To do that:
Select the new view (XIB), then selct the main view, and in the identity inspector, set it's class to your custom class name "AVYSViewController."
Switch to the connections inspector and Control + Drag the "view" outlet to the main view in your XIB.
Also, your project was looking for the MainStoryBoard.storyboard file. So get rid of that setting by selecting your project, then selecting your target, and in the "Summary" tab, delete anything in the "Main Storyboard" field.
Note: I checked to see if your project settings were valid before I deleted the storyboard setting and it returned NO errors, so beware of this problem for future projects.
I think i'm reading the same book as you (Big Nerd Ranch's "iOS Programming"). If so then yeah, I had the same issue as you. Admittedly I am using my laptop to vnc through to a mac box to work on xcode, so I thought it was vnc not capturing the keyboard properly, but turns out it wasn't vnc as I could right-click/cntl-click drag on other things.
Admittedly again I didn't do much research on why it wasn't working, but in the meantime I just right-clicked on the button, which shows the events that the button emits, then click-dragged the "Touch Up Inside" event and dropped it on the controller/owner, which then displayed the actions/methods to hook the event to. If you look on page 17 (if you are reading the same book) then that is the event that was hooked up.
Sorry if there are any obvious glaring errors with what I just say, have only just started reading this book today after a big lunch.
I think you should rephrase you question.. It's very confusing. But if i understand what you are saying, you now have the files open side-by-side in the using the assistant editor. The Xib file on the left hand side, the .h file on the right. correct?
Now you are trying to link the event in the control, to the method you have defined in the .h file. right?
So if you are in fact seeing the methods in the .h file that you want to link to, but the editor is not letting you link to it, then chances are that you have have the xib file side-by-side with the wrong .h file. Are you sure that the .xib file and the .h that are side-by-side are both called controller ? controller.h and controller.xib ?