ksnowlv

回顾过去,总结以往;立足现在,铭记当下;技术为主,笔记而已.

XCConfig文件的使用

| Comments

XCConfig:XCodeConfig文件,可以方便的对项目工程进行配置。只需要引入该工程配置文件即可。

1.分别创建ConfigDebug.xcconfig/ConfigRelease.xcconfig文件

image

2.分别把ConfigDebug.xcconfig/ConfigRelease.xcconfig引入到工程配置中

image

3.编辑ConfigDebug.xcconfig/ConfigRelease.xcconfig文件,分别对other link flagPreprocessor Macros修改设置查看生效情况。

展开”other link flag“后,直接选择Release整行复制到ConfigRelease.xcconfig中,再设置-ObjC-weak_framework UIKit -framework CoreLocation参数。

相同方法修改ConfigDebug.xcconfig即可。

ConfigDebug.xcconfig内容如下:

1
2
3
4
5
6
//:configuration = Debug
OTHER_LDFLAGS = -ObjC -weak_framework UIKit  -framework CoreLocation


//DEBUG __TAOBAOTEST__
GCC_PREPROCESSOR_DEFINITIONS = __TAOBAOTEST__= 0  $(inherited)

ConfigRelease.xcconfig内容如下:

1
2
//:configuration = Release
OTHER_LDFLAGS = -ObjC -weak_framework UIKit  -framework CoreLocation

4.修改完毕后,切换到XCConfigTest TARGETS视图查看设置。

                            other link flag

image

                            Preprocessor Macros

image

5.添加测试代码对 __TAOBAOTEST__宏的测试。 查看debug状态下生效情况。

image

显然,__TAOBAOTEST__debug状态下是生效的。 再测试下release状态下,是不生效的。

其它:

  • 1.CocoaPods中使用XCConfig来进行配置。
  • 2.xcconfigs,一个支持XCConfig的开源库,支持对iOS/Mac OS配置。

总结:不同的项目中,如果可以共用相同的配置环境,这种方式再方便不过了。

Comments

comments powered by Disqus
Included file 'custom/after_footer.html' not found in _includes directory