39

The Xcode project generates Prefix.pch file automatically. When I deleted this file and tried to build, I got build error saying '*_Prefix.pch' file is missing.

  • Is Prefix.pch file is a must for compiling with Xcode?
  • How can I build without the Prefix.pch file?
prosseek
  • 155,475
  • 189
  • 518
  • 818
  • 7
    Why did you delete it? – spender Jan 18 '11 at 19:40
  • 1
    Similar issue, glad someone asked -- I'm checking an Xcode project into TFS, and TFS recommended that I exclude the .PCH file (of Type "Precompiled Header File"). -- Sounds like Xcode isn't smart enough to just recompile the headers if this file is missing, so I'll include it for now. – BrainSlugs83 Jun 24 '13 at 21:53

2 Answers2

69

In Xcode, go to your target's build settings (Command-Option-E, build tab) and uncheck Precompile Prefix Header (GCC_PRECOMPILE_PREFIX_HEADER). You can also remove the value of the Prefix Header setting if you wish.

Prefix headers are compiled and stored in a cache, and then automatically included in every file during compilation. This can speed up compilation, and lets you include a file without adding an import statement to every file using it. They are not required, and actually slow compilation whenever you change them.

ughoavgfhw
  • 39,083
  • 6
  • 98
  • 121
  • 10
    To quote the advice from Xcode itself: "Note: Precompiling the prefix header will be most effective if the contents of the prefix header or any file it includes change rarely. If the contents of the prefix header or any file it includes change frequently, there may be a negative impact to overall build time." I'd suggest you keep the .pch file, and just add import directives for the frameworks you use. You'll almost never change it, and so it will almost always speed things up. – Kris Jenkins Feb 14 '11 at 08:22
0

Yes, you can compile and run the project without .pch file. In Xcode, go to your target's build settings (Command-Option-E, build tab) and uncheck Precompile Prefix Header (GCC_PRECOMPILE_PREFIX_HEADER). You can also remove the value of the Prefix Header setting if u want.