---
title: "IOS开发 - Info.plist和pch文件的作用"
author: "cwlong"
date: "2015-08-20T10:59:35Z"
tags: []
categories: ["移动开发"]
slug: "ios-info-plist-pch"
draft: false
lastmod: "2015-08-20T11:59:38Z"
id: 2236795
url: "https://cwlong.iteye.com/blog/2236795"
---

<span style="color:red"> 
1. [Info.plist和pch文件的作用](http://cwlong.iteye.com/admin/blogs/2236795)

 2. [UIApplication的常见使用](http://cwlong.iteye.com/blog/2236809)

 3. [AppDelegate的代理方法](http://cwlong.iteye.com/blog/2236811)

 4. [UIApplication , AppDelegate , UIWindow , UIViewController 的关系](http://cwlong.iteye.com/blog/2236810)

 5. [IOS程序的完整启动过程](http://cwlong.iteye.com/blog/2236812)
</span>


﹣Info.plist文件﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣我是分割线﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣

![](http://dl2.iteye.com/upload/attachment/0111/0856/26109ecf-52f6-34ed-a0fb-5c51557909cb.png)


*** Bundle Display name (早期版本) Bundle name(新版本)
这个是软件名称,修改这里安装之后显示的文字就是软件名称了

*** Bundle identifier
这个是软件的唯一标示, 假如有一样标示的软件就会冲突

*** Bundle versions string, short  和 Bundle version
这个是软件的版本号, 假如更新软件,发布到appStore会严格遵守版本号的规则

*** Main storyboard file base name
这个是软件的最主要的 storyboard

*** Supported interface orientations
这个是软件屏幕的方向 这个是一个数组,下面三项分别列举的是下图
![](http://dl2.iteye.com/upload/attachment/0111/0872/c9ba3c5a-9d61-3568-9bad-9211d54941fd.png)

Device Orientation
Portrait  竖屏
Upside Down  上下颠倒
Landscape Left  横左
Landscape Right 横右

只要这里勾选了,Info.plist里面的Supported interface orientations就会改变


﹣pch文件﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣我是分割线﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣﹣

苹果官方在xcode6中去掉了pch，为了一些琐碎的头文件引用，可以加快编译速度
所以,需要pch文件,就得手动添加

 1 . 创建PCH文件
![](http://dl2.iteye.com/upload/attachment/0111/0889/1829c73b-c7d4-34c9-bbcb-7ebe41e9a000.png)

 2 . 配置PCH文件
![](http://dl2.iteye.com/upload/attachment/0111/0891/10c23dfd-853f-303a-bca4-b7b176a73b5a.png)

<span style="color:red">配置</span>
注意pch文件的真实路径, 在上图中输入$(SRCROOT)/xx.pch  后,对比实际路径与配置的路径是否相同

3 . PCH文件的作用
pch头文件的内容能被项目中的其他所有源文件共享和访问
所以 : 
1. 存放一些全局的宏(整个项目中都用得上的宏)
2. 用来包含一些全部的头文件(整个项目中都用得上的头文件)
3. 能自动打开或者关闭日志的输出功能


```c

/**
 *  调试阶段 , 一定有DEBUG
 *  发布阶段 , 自动删除DEBUG
 *  
 *  判断是否有DEBUG.智能添加删除NSLog
 */
#ifdef DEBUG
#define CwlLog(...) NSLog(__VA_ARGS__)
#else
#define CWlLog(...)
#endif

```

 
4. 凡是OC的东西,需要添加到

```c


#ifdef __OBJC__
//里面的所有内容,只能用到.m文件中或者.mm文件中
#endif


```