天天看點

Xcode 6.0版本後 添加pch檔案

問題場景:

Xcode 6.0版本之前生成項目的時候會自動生成一個 項目名字-Prefix.pch 這樣的檔案,但Xcode6.0版本後不給自動生成了,需要我們自己建立并且在Build Settings中設定一下。

Xcode 6 之前版本生成的項目:

Xcode 6.0版本後 添加pch檔案

Xcode 6 之前版本pch檔案内部代碼:

//
//  Prefix header
//
//  The contents of this file are implicitly included at the beginning of every source file.
//

#import <Availability.h>

#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif
           

實作步驟

1. CMD + N  在項目的 Supporting Files 檔案夾下 建立pch檔案

Xcode 6.0版本後 添加pch檔案
Xcode 6.0版本後 添加pch檔案

2. 修改 Build Settings 内容

Xcode 6.0版本後 添加pch檔案

3. 修改pch檔案内容(可選)

Xcode 6.0版本後 添加pch檔案

4. CMD + B 測試可用性