每次更新sdk都需要重複的在真機下build,在模擬器下build,然後再合并靜態庫;為瞭解放雙手,嘗試著寫了個指令碼,一步完成以上工作。 一、指令檔
#!/bin/bash#要build的target名target_Name=XXX#編譯模式 Release、Debugbuild_model=Release#擷取工程當前所在路徑project_path=$(pwd)#編譯檔案路徑buildPath=${project_path}/build#匯出sdk地址exportSdkPath=~/Desktop/${target_Name}-SDK/${build_model}if [ ! -d $exportSdkPath ]; thenmkdir -p $exportSdkPath;fi#真機sdk路徑iphoneos_path=${buildPath}/${build_model}-iphoneos/lib${target_Name}.a#模擬器sdk路徑simulator_path=${buildPath}/${build_model}-iphonesimulator/lib${target_Name}.a#合并後sdk路徑merge_path=${exportSdkPath}/lib${target_Name}.a#build之前clean一下xcodebuild -target ${target_Name} clean#模擬器buildxcodebuild -target ${target_Name} -configuration ${build_model} -sdk iphonesimulator#真機buildxcodebuild -target ${target_Name} -configuration ${build_model} -sdk iphoneos#複製標頭檔到目標檔案夾cp -R ${buildPath}/${build_model}-iphoneos/include/${target_Name} ${exportSdkPath}#合并模擬器和真機.a包lipo -create ${iphoneos_path} ${simulator_path} -output ${merge_path}#壓縮合并後的檔案#壓縮後的檔案名稱package_date=`date '+%Y-%m-%d日%X'`sdk_zip_name=lib${target_Name}_${build_model}_${package_date}.zip#跳轉到sdk的輸出路徑cd ${exportSdkPath}#壓縮sdk輸出路徑下的所有檔案zip -r ~/Desktop/${target_Name}-SDK/${sdk_zip_name} ./*#開啟合并後的sdk所在路徑open ${exportSdkPath}#刪除build檔案if [ -d ${buildPath} ]; thenrm -rf ${buildPath}fi
二、使用方法
1.開啟終端使用vi、vim命令建立指令碼檔案 xxx.sh 2.複製以上指令碼內容到 xxx.sh 3.將 xxx.sh檔案匯入sdk工程根目錄下 4.修改對應的工程名target_Name,及編譯方式build_model 5.開啟終端 cd到sdk工程根目錄下 6.終端執行 sh xxx.sh
轉自:
http://blog.csdn.net/zxw_xzr/article/details/79217516