如何通过用户定义的宏x codebuild? [英] how to pass the user-defined macro to xcodebuild?
问题描述
我建立在命令行x codebuild我的项目。不是X中code。我想一些果渣传递给项目,以便它可以影响code。如低于code:
I build my project by xcodebuild in command line. Not in xCode. I want to pass some marc to the project so that it can affect the code. Such as code below:
#if (API_TYPE == 1)
#define URL_API @"https://dapi.xxx.com/1.1/"
#elif (API_TYPE == 2)
#define URL_API @"https://tapi.xxx.com/1.1/"
#elif (API_TYPE == 3)
#define URL_API @"https://api.xxx.com/1.1/"
#else
#error "API_TYPE value error! should be only value 1,2,3 !"
#endif
我想通过code文件外的定义API_TYPE的。如通过X codebuild命令。
但它不喜欢这个工作:
I want pass the define of API_TYPE outside the code files. Such as through xcodebuild command. But It doesn't work like this:
xcodebuild -sdk xxx -target xxx SYMROOT=${XCSYMROOT} API_TYPE=${APITYPE}
的API_TYPE的值没有改变。但SYMROOT的价值发生了变化。
那么,如何可以实施传递值外API_TYPE?
The API_TYPE's value was not changed. But the SYMROOT's value was changed. So how can I implement that passing the value to API_TYPE outside ?
推荐答案
我知道这是一个古老的职位,但为什么不使用:
I know this is an old post, but why not just use:
xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS API_TYPE=1'
如果您希望能够拥有它选择覆盖现有的应用程序定义,只是code是这样的:
If you want to be able to have it optionally override an existing define in app, just code something like this:
#define DEFAULT_API_TYPE 1
#ifdef API_TYPE
#define REAL_API_TYPE API_TYPE
#else
#define REAL_API_TYPE DEFAULT_API_TYPE
#endif
这篇关于如何通过用户定义的宏x codebuild?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!