I’m new to obj-c. Something I’ve noticed is that the .pch file is used to include files across the whole x-code project, but then the same files are also included as well at the top of some .h files, #import for example, what’s the point importing it again at the top of a .h file if it’s already included in the .pch file?
Share
The purpose of precompiled headers is to speed compilation, not to save typing. If you omit an import because “it’s already in the precompiled headers,” then copy that same file to a different project which happens to have a different set of precompiled headers, it will fail. This isn’t likely for common imports like
<Foundation/Foundation.h>, but I’ve seen it happen with other imports.See 4 Ways Precompiled Headers Cripple Your Code.