matt
matt

Reputation: 535325

.xib file not in Compile Sources build phase, but still builds correctly; how can this be?

When you start with an Xcode template that has a .xib file, that .xib file is listed in the Compile Sources build phase. This makes sense to me, because during the build process the .xib file needs to be turned into a .nib file (with ibtool), and it is.

But in renaming my .xib files and adding some new ones, I ended up in a situation where none of my .xib files are listed in the Compile Sources build phase. Instead, they are all listed in the Copy Files build phase. I was not able to fix this. (Don't get me started about that.)

But it turns out I don't have to fix it! When I build, I can look into the package of the built app and I see that it has .nib files, not .xib files. The .xib files are not being copied into the resources folder, even though they are in the Copy Files build phase; they are being compiled, even though they are not in the Compile Sources build phase.

And I can confirm this by looking at the build log:

CompileXIB "MyApp/en.lproj/ViewController~iphone.xib"
CompileXIB "MyApp/en.lproj/ViewController~ipad.xib"

How can this be?

EDIT: Now I can't reproduce my initial premise! As one respondent has said, the template doesn't put the .xib files in the Compile Sources build phase. Yet I certainly ended up in a situation where some .xib files were in the Compile Sources build phase and some where in the Copy build phase, and that's what confused me.

Upvotes: 1

Views: 2766

Answers (1)

Stuart M
Stuart M

Reputation: 11588

When I create a completely new Xcode project for OS X using the "Cocoa Application" template, the project's only .xib file is not listed under "Compile Sources", its listed under "Copy Bundle Resources". So I'm not sure how/why your .xib's are getting listed under Compile Sources in the first place.

As for how they are automatically getting compiled using the CompileXIB command, I suspect it is due to Xcode's Build Rule called "Interface Builder XIB Compiler", which runs for all Interface Builder files.

Upvotes: 1

Related Questions