
Over-relying on precompiled headers can cripple your code!
[This post is part of the Code Smells in Objective-C series. Check out the rest here!]
Precompiled headers were invented for one purpose: to make compiling faster. Rather than parsing the same header files over and over, these files get parsed once, ahead of time. Speed is important! The faster you compile, the faster you can complete the feedback loop to see if recent changes were successful.
In Xcode, you do this by including the header files you want in a “prefix header,” and enabling “Precompile Prefix Header” so they get precompiled. But the idea behind a prefix header is different from precompiling. A prefix header is implicitly included at the start of every source file. For example, if your prefix header is Prefix.pch, it’s like each source file sneaks
at the top of the file, before anything else. This can be handy for project-wide #defines. (Just remember that in general, #defines are a code smell.)
It’s also handy for precompiled headers. The fact that every source file includes these precompiled headers is an artifact of being in the prefix header.
And this is where things start to go wrong…



![Big [self alloc] factory](http://qualitycoding.org/jrwp/wp-content/uploads/2011/12/factory.jpeg)





