PCH file configuration in Xcode-IOS

Source: Internet
Author: User

I. INTRODUCTION

First the PCH file (ie: Prefix Header) is a precompiled file that is created automatically by creating a new project before Xcode 6, but after Xcode 6, Apple officially changes the way it is automatically created to manual manually created later;

This file is primarily used in project engineering to store the more common and stable classes in which the method resources are shared at development time, without having to refer to their header files multiple times in different class files.

However, there are a few suggestions, because the PCH file will be pre-compiled to cache the header file, again compiled without recompiling the contents of the file, thereby increasing the rate of compilation, all try not to develop a low-cost file or macro definition (macro definition can be created by a separate header file for storage, The introduction of the macro file into the PCH will lead to repeated compilation operations in the PCH file, instead reducing its rate so that the file's effect is greatly discounted.

Two. Create

After a general understanding of the role of its PCH file can be created, to play its role, the specific steps to create the following:

1. Right-click the New file or use the shortcut key Command+n, the interface for creating files appears, and the word "PCH" is printed in the search box in the upper right, as shown in:

2. Select the PCH file file and click Create to generate a PCH.

Note: The PCH file is named, it is recommended to start with the project name, for example, the project name is "Testdemo" the PCH file name is "Testdemo-prefix", of course, the actual name will be used.

Three. Configuration

1. Once the file has been created successfully, you need to configure it in Target + Build Settings + Apple llvm9.0-language, as follows:

2. In the 5th place, double-click the pop-up input box to drag the created PCH file into which the path of the PCH file is automatically populated, but the current default generated path is relative path is not an absolute path, once the project file location changes the system will throw an exception error, in order to avoid such a situation occurs, You need to change the existing relative path to an absolute path, as follows:

Insert the path address in its input box to the front of the field in the "$ (srcroot)" double quotation mark, followed by the structure of the project name and folder hierarchy, as shown in.

Note: You can use the "$ (srcroot)/project name/pch file name" method before Xcode 9, but again after Xcode 9, the compilation will still throw an exception warning, trying to keep the folder hierarchy in the relative path and then compile again.

Hope that the above share content can be helpful to everyone, if there is any improper place also please correct the common progress, thank you!

PCH file configuration in Xcode-IOS

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.