iOS Multiple target in the same project

如果新增Target在同一專案下可利用以下方式來區隔Target,避免需要維護兩份Code的成本

選擇 target -> Build Settings -> 搜尋 "preprocessor Macros"

*此範例為新增一個lite的版本
*Debug & Release 兩個版本都要加入

完成後在需要判斷是否為pro或lite版本方式
#ifdef LITE
//lite version
//your code here
#else
//not lite version(i.e. pro)
//your code here
#endif
//-------------------------------------------------------------
#ifndef PRO
//is pro version
//your code here
#else
//not pro version(i.e. lite)
//your code here
#endif
view raw gistfile1.m hosted with ❤ by GitHub


沒有留言:

張貼留言