pch – Pre compile header

.pch file is add to project to make compilation fast. In the .pch file we need to add headers we otherwise call over and over again in every file.

Prefix headers are compiled and stored in a cache, and then automatically included in every file during compilation. Hence as name tells its compile before other files i. e. headers in .pch file compile beforehand instead of add and then compile every time when other file compile.

Swift there is no .pch file 

In Swift there are no headers like objective-C .h file and no macros so there is also no precompiled header. Use extensions, global constants or singletons instead.

Steps to add new PCH file to the project:

1. Xcode -New file > Other > PCH file

2. In the project ‘Build Settings’ option – search’Prefix Header’ – set the value of ‘Prefix Header’ to your PCH file name, with the project name as prefix – (its may be optional— i.e. for project named ‘TestProject’ and PCH file named ‘MyPrefixHeaderFile’, add the value ‘TestProject/MyPrefixHeaderFile.pch’ to the plist.)

3. Go to project-build settings-Apple LLVM 6.0 – language

4. Set Precompile Prefix Header to “YES”

5. Set Prefix Header to .pch file names


Hope you find this blog useful. Please feel free to contact with me in case you have any query, suggestions.  You can comment, like and follow posts.

You can request any topic related to Swift and iOS development.

Donate any small amount you think for this knowledge to grow this forum.                        

To Donate –  paypal.me/SandeshSardar