How to add a pch file in xcode6,

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.