A shell script can batch adding compile flags like `-fno-objc-arc`or `-fobjc-arc` for all the files under the same dir by processing the project file.
xproj 是一个shell脚本,可以给工程批量添加
-fno-objc-arc和
-fobjc-arc编译参数。
如果你的项目是
非arc,但是用到了
arc的第三方,或者反之,这时候你有两种选择,
cocopods或者手动添加。
cocopods当然是推荐方案,但是出于一些原因,你可能不用它。
CMDor
SHIFT),然后双击其中一个文件,接着在弹出的输入框里添加。
但是如果文件巨多,在
Build Phases -> Compile Sources里既有项目原来的文件,又有你刚刚拉进去的文件,考验你耐心的时候到了~ 肿么办?
算了,还是让这个脚本帮你做点什么吧~
第一步需要把用到的文件加到项目里,保证
Build Phases -> Compile Sources里能看到它们
-fno-objc-arc
$ sh xproj -s 需要添加编译参数的文件所在的文件夹 -t 目标工程文件sh xproj -s ./framework -t test.xcodeproj
-fobjc-arc
$ sh xproj -n -s 需要添加编译参数的文件所在的文件夹 -t 目标工程文件sh xproj -n -s ./ZXingObjC -t test.xcodeproj
这个脚本是直接修改你的工程文件,所以会有风险,修改前建议先备份一份。不过考虑到这点,脚本在做任何操作之前会先自动备份一份你的工程文件,该文件以.bak结尾,执行完没有问题之后你可以把它删了,当然也可以留作纪念~
NAME xproj - batch adding compile flags like `-fno-objc-arc`or `-fobjc-arc`SYNOPSIS xproj -s dir [-t xcodeproj] [-n]
DESCRIPTION A shell script can batch adding compile flags like
-fno-objc-arc
or-fobjc-arc
for all the files under the same dir by processing the project file.OPTIONS -n | Used to specify the compile flag to be |
-fobjc-arc
. Default is-fno-objc-arc
. ----------------------------------------------------------------- -e | Used to disable from modifying some extented |build settings
: | 1. Direct usage of 'isa' to 'NO' | 2. Enable Module(C and Objective-C) to 'NO' ----------------------------------------------------------------- -s dir | Specify the dir contains source files ----------------------------------------------------------------- -t xcodeproj | Specify the target xcodeproj file, dafault is | the first of *.xcodeproj under the same dir. -----------------------------------------------------------------AUTHOR Written by QFish <qfish.cn>
COPYRIGHT MIT </qfish.cn>