Can't create new xib files in Xcode projects
This one is a doozy...
My buddy just downloaded the iPhone SDK on his Snow Leopard MacBook Pro. No matter what kind of project he creates (Window Based, View Based, etc...,) he can't create or use his own xib files. The project will compile and run fine until he adds a new xib file.
Here are some symptoms:
- When he selects a pre-generated xib in Xcode (such as MainWindow.xib), no preview is shown on the right hand side. Double clicking on this file will open it in interface builder (This is correct behavior).
- When he selects his own custom xib, the preview pane displays the XML content of the xib. Double clicking on his custom xib opens up the XML file in Xcode - as if it were a standard code file (This is jacked up).
- Opening his custom xib from finder opens it in Interface Builder.
- When building the application, the build warning says something to the effect of "Warning: No rule to process file /path/to/CustomXib of type sourcecode.xib for architecture i386"
At runtime he gets the error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] was unable to load开发者_如何学编程 a nib named "MyCustomXib"'
We've uninstalled Xcode from the command line and reinstalled. I've verified that it's the right version for his machine. I'm stumped!
Yes, I also had this problem and also upgraded directoy from Tiger to Snow Leopard. The fix for me was changing the file type of the nib file from sourcecode.xib to file.xib (control click on the nib file, select "Get Info", and modify the "File Type" in the dropdown.
The error...
Warning: No rule to process file /path/to/CustomXib of type sourcecode.xib for architecture i386"
... suggest the nib is for some reason in the "Compile Sources" build phase. Open the target and then open Compile Sources and see if the nib is listed there. If it is, move it to "Copy Bundle Resources" and try to compile again.
Try changing the file type of the xib from "sourcecode.xib" to "file.xib". "sourcecode.xib" seems like it would try to treat the file as a source file, and not as the (default) xib file.
This is a total cop out, but after screwing around with Xcode, OS X, the terminal and seeing no progress, we've decided to wipe the machine and start fresh. The bug may be a consequence of upgrading directly from Tiger to Snow Leopard, and having some strange left-over settings.
It seems my xib- file was saved with wrong file info when created by File->New_file->Create an UIViewController subclass in XCode.
When I changed the file info into the same as for the MainWindow.xib, and also moved it from the Target compile folder, it worked fine; it both compiled and started in interface builder.
PS: I too upgraded directly from Tiger to Snow Leopard, so that could be a candidate for mixing the settings of Xcode?
精彩评论