生成用于iOS模拟器安装的包

1
2
# 查看打的包的架构类型
lipo -info myProject.app/myProject
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 切到项目目录
cd myProject

# 定义一下要用的变量
Poj_Path=`pwd`
Build_Sim=$Poj_Path/build/build-Sim/

# 清除每次编译结果
rm -rf build/derived/Build/

# 使用xcodebuild命令编译用于simulator的*.app包(Release)
# 由于推送sdk没有支持模拟器所以要设置ONLY_ACTIVE_ARCH=YES
xcodebuild ONLY_ACTIVE_ARCH=YES -workspace "myProject.xcworkspace" -scheme "myProject" -configuration Release -sdk iphonesimulator -derivedDataPath "build/derived"

if [[ $? -ne 0 ]]; then
echo "编译失败"
exit 1;
fi

# 到*.app目录
cd derived/Build/Products/Release-iphonesimulator

# 利用/usr/libexec/PlistBuddy获取现在的版本号
BUILD_VER=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" myProject.app/Info.plist)
BUILD_CODE=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" myProject.app/Info.plist)
echo $BUILD_VER '_' $BUILD_CODE

# 建一个文件目录
mkdir $Build_Sim

# 压缩*.app文件到Build_Sim目录下
zip -r $Build_Sim/myProject.app.zip myProject.app

if [[ $? -ne 0 ]]; then
echo "压缩失败"
exit 1;
fi

echo "build simulator product success!"
exit 0;