Tuesday, October 06, 2009

Objective C Hello World, Part II

I finally fixed the problem I was having with my nib file not getting found! Turns out the MyViewController.xib was set as a file type of "sourcecode.xib"; switching it to "file.xib" solved the problem. File type can viewed and updated by right-clicking the MyViewController.xib file anywhere in Xcode and selecting "Get Info".

I figured out this fix by examining the MoveMe sample app project -- which has been running just fine in the simulator -- and looking for differences with my HelloWorld project. I had already tried going through a similar but different HelloWorld tutorial, but ended up with the same error. I had also tried uninstalling and reinstalling the SDK.

One clue there was something wrong with the .xib itself: double-clicking MyViewController.xib in Xcode never opened the file in Interface Builder. Instead, the file's underlying XML would open, complete with color-coding. I could only get it opened in IB by selecting "Open With Finder" from the context menu, or using File > Open in IB. All of my self-made nibs behaved this way.

I have no idea why this happened. Maybe it's a bug in this Snow Leopard build or Xcode (version 3.2, SDK build 10a432)?

One other issue: I was getting a warning when I compiled MyViewController.xib about there being "no rule to process file". The warning went away when I moved the reference to MyViewController.xib out of Targets > HelloWorld > Compile Sources and into Targets > HelloWorld > Copy Bundle Resources. I don't know if this was important.

No comments: