PCH file is a header file, except that the class of the header file can be used in the global, so it is very convenient, and do not have to write in each class A number of repeating class header file, as long as the use of the class's header file into the PCH file inside the line, of course, there is a macro definition, this must also be necessary.
So how to use it so good.
1.
Command + N Create a new PCH file, and select it in Xcode8.2 (because the PCH file is not a PCH file type below),
(There is no PCH file above, need to pull down, pull to the bottom you will see.) )
Next, then the name of the PCH file is entered and then it's half as good as it goes. There will be some comments in the newly built document, which can be deleted.
All third-party classes and their own classes of header files can be inside this, of course, the macro definition is definitely indispensable. Configuration (PCH files also need to be configured, create a good first step, not configuration is not used, after the configuration can be used) can be in the entire project to invoke the class here.
2.
is to configure the PCH file.
The first step: in the project targets inside building setting search Precompile Prefix Heade, and then the Precompile Prefix header to the right of the no change to Yes:
Second step: Continue to search prefix Heade, find prefix heade, in the bottom line 34th.
Then find the PCH file, show in finder, then edit prefix heade, double-click on the right, followed by the PCH file just pulled in with the mouse is OK.
One last episode:
Just that method (that is, the file is pulled in this way) only suitable for personal development, not suitable for cooperative development, because the storage directory has a computer name and the user's name, change a computer will be an error can not find this file, how to do???
In fact, it is very simple, because this is the absolute path, is dead, the solution is to change the path to a relative path, is relative to the position of the project.
$ (srcroot) represents the project's location as the folder where the project is placed, just refer to him.
$ (srcroot) is the PCH folder on the left, then the prefix Heade in this project should be $ (srcroot)/prefixheader.pch,command + b You will find the path to the first method is the same.
In this way, cooperative development is no problem. All right, that's it.
The role and configuration of the PCH file