How to add a pch file in xcode6,
When you create a project in Xcode5, the system automatically creates a pch (Precompile Prefix Header) file named by the project name, during development, you can include widely used header files and Macros in this file, and the compiler automatically adds the header files in the pch file to all source files, in this way, you can directly use the content in the header file without using import when you need to use the relevant classes, which brings programming convenience to the programmer. However, the Precompile Prefix Header file is removed from Xcode6.
Xcode6 removes the Precompile Prefix Header mainly because the Prefix Header greatly increases the Build time. Without the Prefix Header, you must manually import the Header file through @ import. This reduces the Build time while losing programming convenience.
In Xcode6, how does one manually add a Precompile Prefix Header?
(1) Add a pch file to the project. You can continue to use the "Project name-Prefix. pch" in Xcode5 ":
(2) modify the project configuration file and add the path of the created pch file to the precompile header option in building setting (Add "$ (SRCROOT) to the path) /Project name/pch file name "):
Now, you have manually added the pch file and compiled the program. If there is an error, check whether the added path is correct. (If you write $ (SRCROOT) at the beginning, it will be created in the root directory. If it is $ (PROJECT_DIR), it doesn't matter)
Note that when Precompile Prefix Header is switched, the pch compilation and import mechanisms are very different:
(1) If the Precompile Prefix Header is YES, pch will be pre-compiled, and the pre-compiled pch file will be cached to speed up compilation. (2) If the Precompile Prefix Header is NO, pch will not be pre-compiled. Instead, it will be compiled once in every. m file of the framework class library used for its import, reducing the compilation speed.
Conclusion: Since Apple removed the Precompile Prefix Header file from Xcode6, you can use as few pch files as possible during the development process. If you want to use it, try to reduce the content in the pch file as much as possible, reduce program dependency on pch files.