把以下字段保存到记事本中,不要后缀,然后放在unity3d生成的xcode工程中,和.同一目录然后双击则可生成ipa,前提是必须安装了xcode并且工程可以顺利编译,如果在xcode中的key设置正确会自动签名:
#!/bin/bash
#--------------------------------------------
# 把 xcode 工程打包为 ipa 包
# 作者:栖云
# E-mail:yslflsy@qq.com.com
# 创建日期:2015/03/21
# 使用前请修改为工程的正确路径,并在 xcode 工程上设置好为 Release 编译模式(PROJECT->info-> Use [Release] for command-line builds
#--------------------------------------------
#脚本所在目录
sh_path=$(cd "$(dirname "$0")"; pwd)
#工程绝对路径
project_path=$sh_path
cd $project_path
echo $project_path
#build文件夹路径
build_path=${project_path}/build
echo $build_path
#工程配置文件路径
project_name=$(ls | grep xcodeproj | awk -F.xcodeproj '{print $1}')
project_infoplist_path=$project_path/Info.plist
#取版本号
bundleVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleVersion" ${project_infoplist_path})
#取bundle Identifier前缀
bundlePrefix=$(/usr/libexec/PlistBuddy -c "print CFBundleIdentifier" `find . -name "*-Info.plist"` | awk -F$ '{print $1}')
echo "当前版本号为: " $bundleVersion
#清除旧的生成文件
rm -f -r $build_path/$project_name
#编译工程
cd $project_path
#clean项目
echo "编译前要执行清理操作吗?(输入 y/n 后回车)"
read need_clear
if [ $need_clear == "y" ];
then
echo " "
echo "=================================="
echo "=========== 开始清理项目 ============"
echo "=================================="
echo " "
xcodebuild clean
fi
echo " "
echo "=================================="
echo "============ 开始生成项目 ==========="
echo "=================================="
echo " "
xcodebuild || exit
#打包
cd $build_path
ipa_name=$(ls | grep app.dSYM | awk -F.app.dSYM '{print $1}')
echo [$ipa_name]
/usr/bin/xcrun -sdk iphoneos PackageApplication -v ./$ipa_name.app -o ${build_path}/$ipa_name.ipa
echo " "
echo "=================================="
echo "========= 打包签名 ipa 包完成 ======="
echo "=================================="
echo " "
echo " "