cocos集成了打包命令 cocos compile -p ios
在这里并没有采用这个方案,而是编写自己的脚本, 理由如下
查了一下资料xcode 支持命令行
如果不清楚, 直接命令行 xcodebuild -help即可查看所有命令
为了便于管理和扩展 我们在项目根目录下新建了两个文件夹
- build/ios:脚本目录,
- publish/ios:ipa输出目录
直接上脚本, 将XXXX换成自己的证书文件,工程路径即可
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/bash
projectPath=
"$1"
schemeName=
"$2"
dir
=
"$( cd "
$(
dirname
"${BASH_SOURCE[0]}"
)
" && pwd )"
cd
$
dir
cert=
"XXXXXX"
profile=
"XXXXXX"
sdk=iphoneos8.4
if
[ ! -d
"${projectPath}/bin"
];
then
mkdir
-p
"${projectPath}/bin"
fi
#xcodebuild -project "${projectPath}/lddoudizhu.xcodeproj" -scheme ${schemeName} -sdk ${sdk} -configuration Release clean
xcodebuild -project
"${projectPath}/lddoudizhu.xcodeproj"
-scheme ${schemeName} -sdk ${sdk} -configuration Release DEPLOYMENT_POSTPROCESSING=YES CONFIGURATION_BUILD_DIR=
CODE_SIGN_IDENTITY=
"${cert}"
PROVISIONING_PROFILE=
"${profile}"
build
xcrun -sdk iphoneos PackageApplication -
v
"${projectPath}/bin/${schemeName}.app"
-o
"${projectPath}/bin/${schemeName}.ipa"
|
我们再编写一个python脚本调用shell并传递schemeName
# coding=utf-8
# !/usr/bin/python
import
os,shutil
datetime
class
Buildios:
def
__init__(
self
):
.
dir
=
os.path.split(os.path.realpath(__file__))[
0
]
.projectPath
=
+
"/../../frameworks/runtime-src/proj.ios_mac"
.outputPath
"/../../publish/ios"
.appName
=
"XXXXX"
.schemeName
"XXXXXXX"
build(
):
os.system(
"sh build_ios.sh "
+
" "
.schemeName)
if
not
os.path.isdir(
.outputPath):
os.mkdir(
.outputPath)
#获得当前时间
now
datetime.datetime.now()
outputFile
"/"
"_"
+
now.strftime(
"%Y%m%d%H%M"
)
".ipa"
shutil.copy(
"/bin/"
".ipa"
,outputFile)
print
(
"[Success] "
outputFile)
run(
):
os.chdir(
dir
)
.build()
buildios.run()
|
以后我们可以继续完善python,比如在不同的平台下 预先进行文件夹的整理,在执行打包脚本之前先将lua编译成字节码并加密,尽情的发挥想象吧!