I have a rather strange problem that I can't quite get to the bottom of just yet, and I want to document it here because I haven't seen this problem discussed anywhere else.
I have a iPhone app that I was developing under Xcode3. This was working perfectly and I had done some ad-hoc distribution that also worked perfectly on devices.
Then I upgraded to Xcode4 and the next time I did an ad-hoc distribution my app crashed on startup. Needless to 开发者_如何转开发say that it worked in the simulator and in devices hooked up to my development machine. The crash logs were none too helpful, they indicated a crash in main.m, in the standard call to UIApplication. I, of course, had never changed that file. After much digging and piecing together I discovered the problem.
Xcode thought that the file type of my *.xib files was text.xml instead of file.xib and so was only copying these files to the app bundle instead of compiling them. The app was then crashing on startup because it couldn't find the MainWindow.nib file.
By tracing back through my subversion checkins I found that the file types, as recorded in the project.pbxproj file within xcodeproj, changed in the first checkin after the Xcode4 upgrade. I have no idea as to how or why that happened. Nor I can see through the UI how I would influence that setting and I didn't even open some of the xib's that changed. (To fix my problem I modified the pbxproj file in a text editor).
So, does any-one have any insight as to how or why this could have happened?
I'm running into the same problem with my existing xcode3 projects that I have migrated to xcode4.
I tried @jaylinn's solution, but I too found the file already had lastKnownReference.
I have been able to resolve this by deleting the .xib files from the project (Remove Reference Only) and then re-adding them to the project. It's a bit of a pain, but it works.
Hope that helps. -Mike
Here's what fixed it for us. The XIB was identified as an "explictFileType" which does not appear to be recognized in Xcode 4.
Look for a line like this in your project file (open with a text editor) ...
C9B10BEA11D9084800F10866 /* Record.xib */ = {isa = PBXFileReference; explicitFileType = file.xib; path = Record.xib; sourceTree = ""; };
And change it to this ...
C9B10BEA11D9084800F10866 /* Record.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Record.xib; sourceTree = ""; };
精彩评论