. pch File
Also a header file, the contents of the PCH header file can be shared and accessed by all other source files in the project. is a precompiled file.
First, let's talk about the role of PCH:
1. Store some global macros (macros that are used throughout the project)
2. Used to include all header files (header files that are used throughout the project)
3. Can automatically turn on or off the log output function
which can be used to store shared information: Other pages need to import the header file and screen width, height settings, the need for third-party library header files, etc.;
Create PCH files->file->new file, select the PCH file in other under iOS and click Next
2. Related Settings in the project
Open the project target inside building setting search Prefix header, and then the Precompile Prefix header to the right of the No to change to Yes:
3. Then double-click the prefix Header line to the right of the empty area pop-up input box enter "$ (srcroot)/project name/PCH filename"
To add, sometimes it may not be possible to remember the full path "$ (srcroot)/xxx/xxx.pch",
The easy way to do this is to drag and drop, double-click Open prefix Heade, pop up an option box,
After selecting the corresponding PCH file, just drag it in, it's OK!
4. After the addition is complete, you can define the macro in the PCH file, and then add the COMMAND + B to pre-compile.
Pre-compiled PCH files are cached to improve compilation speed
Use of. pch files in iOS development and related engineering settings