Use of IOS. pch files

Source: Internet
Author: User
Tags uikit

What is the. pch file
Precompiled header file (general extension. PCH) is a project in which the more stable code is pre-compiled and placed in a file (. PCH). These pre-compiled code can be any C/s code--or even an inline function--that is more stable throughout the project, i.e. code that is not often modified during engineering development.

My own understanding is this. pch file is defined as something that can be used in a. pch in any file within the entire project.
What is defined in the file and does not import any header files

My approach:
1. First, I'll add an. h file to write a macro definition

After the successful creation  , you can add some of the macro definitions you need in this file.  
For example: my
  header.h//  my9xiushow////  Created by Taoli on 16/12/15.//  Copyright 2016 LSS. All rights reserved.//#ifndef header_h#define header_h//Font Color # define RGBACOLOR (r,g,b,a) [Uicolor colorwithred: (r)/ 255.0 Green: (g)/255.0 Blue: (b)/255.0 alpha:a] #endif/* header_h */

I just added a macro to this side.

2. Create a. pch File New file-select PCH file

This allows you to create a. pch file   Sprefixheader



3. Connect the Header.h with the. pch file

Open a. pch file Add import "Header.h"
#import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import "Header.h"

The code is as follows:
#ifndef sprefixheader_pch#define sprefixheader_pch//Include Any system framework and library headers this should be Included in all compilation units.//you'll also need to set the Prefix Header build setting of one or more of your Targ ETS To reference the this file. #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import "Header.h" # endif/* SPREFIXHEADER_PCH */

4. Associating a. pch file with a project

buildsetting-Search Prefix header-Find prefix header

1 set the precompile prefix header  to Yes  so that the file is cached after compilation so that it   can speed up the compilation again
2 Prefix the Header and then double-click and drag the newly created. pch file into it (try it a few times at a time and then just do it) drag it in and then change the directory to only the name of your project./.pch filename Just like I did . My9xiushow/spreficheader.pch


5. This will be done: after the commend+b compiled the project and then you can use the



If for water why not abandon the stormy sea

Use of IOS. 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.