XCode自動打ipa包腳本 命令


XCode 新建文件 選擇other Shell script  放入下面命令行。
#工程絕對路徑
#cd $1
project_path=$(pwd)
#build文件夾路徑
build_path=${project_path}/build

#工程配置文件路徑
project_name=$(ls | grep xcodeproj | awk -F.xcodeproj '{print $1}')
project_infoplist_path=${project_path}/${project_name}/${project_name}-Info.plist
#取版本號
bundleShortVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" ${project_infoplist_path})
#取build值
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}')


cd $project_path
echo clean start ...
#刪除bulid目錄
if  [ -d ${build_path} ];then
rm -rf ${build_path}
echo clean build_path success.
fi
#清理工程
xcodebuild clean || exit
#去掉xcode源碼末尾的空格
#find . -name "*.[hm]" | xargs sed -Ee 's/ +$//g' -i ""

#編譯工程
xcodebuild  -configuration Release  -workspace ${project_path}/${project_name}.xcworkspace \
-scheme ${project_name} \
ONLY_ACTIVE_ARCH=NO \
TARGETED_DEVICE_FAMILY=1 \
DEPLOYMENT_LOCATION=YES CONFIGURATION_BUILD_DIR=${project_path}/build/Release-iphoneos  || exit


if [ -d ./ipa-build ];then
rm -rf ipa-build
fi
#打包
cd $build_path
mkdir -p ipa-build/Payload
cp -r ./Release-iphoneos/*.app ./ipa-build/Payload/
cd ipa-build
zip -r ${project_name}.ipa *

echo ${build_path}/ipa-build/${project_name}.ipa
#找到桌面路徑
cd ~/Desktop
#echo Desktop dir
#echo $(pwd)
#拷貝文件
cp -r ${build_path}/ipa-build/${project_name}.ipa  $(pwd)
#清空bulid目錄
cd ${build_path}/ipa-build
rm -rf Payload
if  [ -d ${build_path} ];then
rm -rf ${build_path}
fi

 

保存到桌面爲ipa_bulid.sh。命令行進入項目根目錄xcode

 將文件拖入終端 回車執行。app

執行完畢 打包ipa 自動保存到桌面 。證書須提早配好(能夠不選release 模式。命令行自動選擇)iphone

此命令行僅供學習。初試牛刀,再接再礪。學習

 

 打包有關知識:ui

http://blog.csdn.net/linfei2707/article/details/7100514spa

相關文章
相關標籤/搜索