iOS xcode设置

时间:2022-07-23 11:01:14

Xcode build search paths

c/c++ 头文件引用问题
include <> 引用编译器的类库路径下的头文件
include “” 引用工程目录的相对路径的头文件

include 是编译指令,在编译时,编译器会将相对路径替换成绝对路径,因此,头文件绝对路径=搜索路径+相对路径。

Xcode Build Settings 下 Search Paths设置搜索路径

Header Search Paths:头文件搜索路径设置

$(SRCROOT)宏和$(PROJECT_DIR)宏都指xxx.xcodeproj所在的父目录

例如:引用工程testDemo/scr/test.h 头文件,

Header Search Paths中添加$(SRCROOT),引用为include “scr/test.h"
如果在Header Search Paths中添加$(SRCROOT)/scr,那么头文件引用直接引用 include “test.h”

如果设置了 Always Search User Paths 为 yes,编译器会先搜索User Header Search Paths路径下的目录,在这种情况下include <string.h>,User Header Search Paths 搜索目录下的文件会覆盖系统的头文件  (Use the User Header Search Paths for paths you want searched for #include "..." and use the Header Search Paths for #include <...>. Of course, if you check the option to Always Search User Paths, then #include <...> will also work for the user paths.  < > is for frameworks -- .a and .frameworks "libraries" -- and it doesn't matter if it's a system framework, one of your own or a 3rd party (like Boost.)  " " is for project headers -- .h files that are part of the set of files being compiled.)

Architectures

1、Architectures(指令集)——设置你想支持的指令集,目前ios的指令集有以下几种:

(1)armv6,支持的机器iPhone,iPhone2,iPhone3G及对应的iTouch 2,

(2)armv7,支持的机器iPhone4,iPhone4S

(3)armv7s,支持的机器iPhone5,iPhone5C

(4)arm64,支持的机器:iPhone5S

机器对指令集的支持是向下兼容的,因此armv7的指令集是可以运行在iphone5S的,只是效率没那么高而已~

Valid architectures : 指即将编译的指令集。

Build Active Architecture Only : 是否只编译当前适用的指令集。

现在是2014年初,其实4和4S的用户还是蛮多的,而iphone3之类的机器几乎没有了,所以我们的指令集最低必须基于armv7. 因此,Architecture的值选择:armv7 armv7s arm64(选arm64时需要最低支持5.1.1,这块不太明白)

1、如果想自己的app在各个机器都能够最高效率的运行,则需要将Build Active Architecture Only改为NO,Valid architectures选择对应的指令集:armv7 armv7s arm64。这个会为各个指令集编译对应的代码,因此最后的 ipa体积基本翻了3倍。(如果不在乎app大小的话,应该这样做)

2,如果想让app体积保持最小,则现阶段应该选择Valid architectures为armv7,这样Build Active Architecture Only选YES或NO就无所谓了。

Base SDK ----当前编译用的SDK版本。

iPhone OS Deployment Target----指的是编译出的程序将在哪个系统版本上运行。

iPhone OS的版本众多,很多用户由于各种各样的原因没有升级到最新版,这就给我们开发者带了麻烦。作为开发者,我们都希望软件的受众越多越好。怎么样让软件尽量适应最多的iPhone OS?

这里我们就应该了解iPhone项目的Base SDK和iPhone OS Deployment Target。 Base SDK指的是当前编译用的SDK版本。iPhone OS Deployment Target指的是编译出的程序将在哪个系统版本上运行。

用更简单实用的语句描述如下:

Base SDK设置为当前xcode所支持的最高的sdk版本,比如"iphone Device 4.0"。iPhone OS Deployment Target设置为你所支持的最低的iPhone OS版本,比如"iPhone OS 3.0"。

这样设置之后,你的程序就可以运行于从iPhone OS 3.0 到 4.0的设备之上。当然,前提是你没有用到4.0新加的API。

Project的设置默认并不被Targets继承,只有当Targets的设置加入了$(inherited)时才被继承