Xcode manually add PCH files after iOS8

Source: Internet
Author: User

1, PCH Introduction
PCH file is a precompiled file, in the case of more project files, the duplicate import (#import "XXX.h") the same file is unavoidable, although can be repeated import, but for the simple and clear project, PCH file is necessary. For example, when I request the network will use the AFN, when only in the PCH file to write #import "Afnetworking/afnetworking.h", then all the files of the project will no longer import the header file, it can be used directly. When IOS6, Xcode will default to create the PCH file for us, but after the Apple IOS8 will not help us create, so we can only add manually.

2. Create PCH File
(1) Click Other under iOS to locate the PCH File, and then next

(2) A name for the file, remember to put the target on the hook, do not tick, you will have problems, and then create on it

(3) After the creation is complete, write the #define ScreenWidth [UIScreen Mainscreen] in the PCH file. BOUNDS.SIZE.WIDTH a macro definition, and then use in a file, you will find the error, then you need to modify the PCH file path, Texture:

(4) in the figure of the previous step, double-click there, double-click, in the pop-up box write $ (srcroot)/demo1/ Prefixheader.pch,demo1 replaced with the name of their own project, PREFIXHEADER.PCH replaced by their own PCH file name, remember to put. PCH Plus, and then enter the.

(5) Some students may find that the compile time or error, said the file does not exist, that is the path of the problem, it does not matter, there are 2 ways to solve, the first is to click the project name->show in the Finder, and then find the PCH file, drag the file to the first floor of the project, the project in the Red file deleted , and then import the PCH file into the corresponding folder, compile on it, the second is to modify (srcroot)/demo1/prefixheader.pch This path, also click on the project name->showinfinder, and then find the PCH file, Look at the relative path of the PCH file under the Project name folder, and then modify the path to (srcroot)/demo1/prefixheader.pch This path, also click the project name->show in Finder, and then locate the PCH file, Take a look at the relative path of the PCH file under the Project name folder, then modify the path to (srcroot)/relative path, compile successfully, and use the

(6) The most important point is that the actual path to and fill in the same path,

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.