I'm trying to create and show new window in my simple Cocoa application:
myWindow = [[MyWindowController alloc] initWithWindowNibName:#"MyWindow" owner:self];
[myWindow showWindow:self];
It's working well with basic nib file without localization, but as soon as I turn on localization for this specific nib file (using Xcode "localize" option available form file inspector), the application gives me this error when executing the code above:
-[MyWindowController loadWindow]: failed to load window nib file 'AuthWindow'.
Should I change the way I'm initializing my window controller when using localized nibs? It fails only when nib containing a window is localized (with just one language - English), when there is no localization configured - the window is loaded and appears on the screen as it should. I can't find the right answer, I'm new to Cocoa on OSX, but have some experience with CocoaTouch and developing for iOS.
I restarted Xcode and the error went away...
I don't know... but whatever...
initWithWindowNibName: can locate a .nib file in a localization directory such as en.lproj/. The problem is, sometimes Xcode forgets to compile a .xib file (an Interface Builder file in XML format, which you usually play with) into a .nib file, or a binary format - especially when the .xib file is just localized by clicking "Localized..." button.
If you open $build_dir/Your.app/Contents/Resources/$locale.lproj you will find some xibs only copied from the source directory.
Relaunching Xcode will resolve the situation, while I'm not sure what the cause is and why relaunching does the trick.
It's an old question, but I found a different solution than those above. In the nib in question, go to the identity panel and make sure the nib's target membership is checked.
I had an error like this. What solved it for me was to make a backup copy of the xib file, delete it from xcode, restart xcode, then add it back. Go figure...
Related
I am trying to add a custom window as a .xib file to my existing OSX project. When I added the xib file, I make sure the target is checked in the "Add to targets"
However, when I view the property of the xib file, it shows that it's not part of the desired target group
The target isn't checked
Then I experimentally add the xib files into "Copy Files" in the build phases. Now the xib file's property looks a bit different, the target is checked but grayed out.
Checked but grayed out target group
Now when I try to access the xib file, for example, using
bool suc = [[NSBundle mainBundle] loadNibNamed:#"GiphyDialog" owner:nil topLevelObjects:nil];
It always returns false.
Or if I try to load the xib file using a window controller:
[[Windowcontroller alloc ]initWithWindowNibName:#"GiphyDialog"];
NSWindow* win = windowController.window;
Even though the File's owner and the window reference are correctly configured (tested in a brand new project successfully), I always failed to load the window with the message "failed to load window nib file 'GiphyDialog'."
How can I add the xib files correctly to the desired target? It's really strange that with a newly created project, I have no problem adding xib files to the target, but with this project, it simply doesn't work. What am I missing?
Xibs must be added to Copy Bundle Resources, not Copy Files.
So I manage to figure out the problem. In my XCode project there is no Copy Bundle Resources under the Build Phases. But I can add it by clicking the + button on the top-left corner of Build Phases. Adding the xib file to the Copy Bundle Resources then fix my issue.
I am trying to give an object in the interface builder a custom class. When typing in the class name in the Identity Inspector it automatically finishes the line as its already present in the dropdown list of available classes.
However after entering the class the page comes up with a padlock image and clears the class name.
What is the cause of this and how can I rectify it?
firstly, you must reload xcode
if it not work you must have subclass associate with it in IB
Create CustomClass:UITableViewCell then drop UITableViewCell to IB and then just type the name
If dropdown list not display, reload Xcode
Assuming you've specific the right IB object (e.g., a dynamic cell prototype, whose default class is UITableViewCell) and your custom class is defined correctly (as a subclass of UITableViewCell, itself), then I have a couple of thoughts of what you might try:
Sometimes exiting and restarting Xcode is often enough.
Also try selecting "Clean" from the "Build" menu (or press shift+command ⌘+K).
In the worst case scenario, sometimes you have to exit Xcode and delete the DerivedData folder and then restart Xcode. To find the derived data folder, press command ⌘+, (comma) and go to the last tab, "Locations", and click on the arrow next to the "Derived Data" folder:
Having pulled up that folder in Finder, quit Xcode, delete the contents of that DerivedData folder in Finder (after quitting Xcode), and then restart Xcode and try again.
I think I have found the solution (not sure if I have found a fix for the actual problem or just found a way around it)...
I changed the Lock dropdown setting to Nothing and it now allows me to set my own custom class to the Object in the file.
Whats strange is that the document lock was previously set to Inherit (Nothing) anyway so not sure what the difference is here.
Like many of the prior 'MainStoryboard missing in NSBundle' questions, I've got the same prompt but have found no issue with naming and no issue with if the storyboard exists within an area XCode likes.
All the pointers lead to the same file, I've changed my .plist a good 5 times to make it responsive to the same call as found in Build Stages. Now I'm all kinds of tired of this crap because I just want to program, not debug compiler screw ups.
It happened in an instant and now I've been a day and a half without an interface that works. How should I proceed?
I got the following similar error in XCode 4.3.3:
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Could not find a storyboard
named 'MainStoryboard'
I fixed it by doing the following:
Make sure your -info.plist has Main story board file based name = MainStoryboard
Right Click on your Story Board file in Xcode and select Delete then References Only
Right Click on your project and select Add Files to [Your Project]
Navigate to the story board file, found in the en.lproj folder in your projects directory and add it
Clean, Recompile and Run and you should find it works.
Got the idea from this SO post: XCode 4.2 MainStoryBoard Not Found
Just as a reference to other first timers like me reading through all the SO questions about missing storyboards:
Don't put ".storyboard" at the end of your file name in your plist file. It should look like this:
Main storyboard file base name: MainStoryBoard
When you create a new *.storyboard file, Xcode (version to date) doesn't automatically add it into your build resources. To fix this you must add the file under "Copy Bundle Resources".
Select the Xcode project icon and navigate to: Targets > Build Phases > Copy Bundle Resources
Click the + button at the bottom to add the storyboard file.
After cleaning my Projekt i have every time this Problem......
My solution is:
move the Main.Storyboard intro trash.
Then "Add Files" select your soryboard, after moving the Main.stpryboard from trash zo your desktop.
and, voila. The Error ist gone.
Considering that there is not too much information about your problem, My best bet would be to go to the package Info, and see if the Main Storyboard is set to whatever your main storyboard is.
As of iOS 9 use just "Main" for storyboard name, worked for me.
Ralph Willgoss's steps didn't work for me. I managed to solve it by copying all the viewcontrollers in the storyboard, deleting it (Move to Trash, not Remove Reference), making a new one (rightclicking the project folder and clicking New File, selecting Storyboard) with the same name as the one I deleted and then pasting the copied contents into it.
Please show me how I can add and implement the libPusher library to my Objective-C iOS project
This is my first post on StackOverflow
I've just started working in Objective-C iOS app development for a company that I co-founded with a couple of colleagues. Our first app needs to have the libPusher library implemented in its porject. Right now, I'm at a crossroads completing the following task of adding and implementing it on Xcode 4.2:
Simply copy libPusher-combined.a and the contents of the headers directory into your Xcode project..
Source: http://github.com/lukeredpath/libPusher/wiki/Adding-libPusher-to-your-project
What does it mean by "copy"ing those files, and where should it be copied to? Can anybody who has experience with libPusher give me specific details as a list and source code on how to execute this so I can understand it better? I would truly appreciated any help, it will get our company up and running for us getting our app functioning and ready for reviewing submission to Apple Developer staff. The link I've provided will tell you more on what I'm talking about, if I need to specify anything I'll create a new post. Thanks!
What "copy" means in this context is that you want to drag and drop the .a (library) file and the header files (all the .h files) into your new Xcode project (to be precise: the file inspector is the list of files along the left side of the workspace window).
To copy anything to an Xcode project, find it in the finder, highlight all of the files you want to copy over (or just take the folder it comes in), then drag everything over the Xcode icon in the dock.
If Xcode is full screen (lion), the icon will kind of blink, then enter Mission Control mode, you then hold the files over the correct project and drop them into the Xcode file tree.
Make sure that your application is checked as a target for those files!!
If Xcode is not full screen, just drag the files or folder into the Xcode file tree and they will be added.
To link to a static library, just navigate to the name of your project>Info>Framworks. Click the plus, then select your framework if it isn't already there.
I started to create an app using tabbar app template provided in xcode. Then I wanted to change the names of the files: FirstViewController should become YellowViewControler and FirstView.xib should become YellowViewcontroller.xib. Changing the name of the xib wasn't done right. It became red as if it didn't exist in the project. So: how should I change the name of the xib files?
Use the "Refactor" tool of Xcode.
This will manage the renaming of the XIB file, the renaming of the interface & implementation of the source file containing the definition of the ViewController, the renaming of your class declarations/definitions, and any references that are used anywhere in your projects, all of this in one action.
Rename the stuff back to what their original name was (FirstViewController) and then go to the interface file for it (.h) and right click on the class name (FirstViewController) and click refactor. This should make sure everything gets changed correctly.
Source this question
Most likely your viewcontroller name still linked to previous owner therefore open the viewcontroller.xib in source code and find the owner and changed to current name. It will fix the problem right away.