if [ "${ACTION}" = "build" ]
then
#要build的target名
target_Name=${PROJECT_NAME}
echo "target_Name=${target_Name}"
#build之后的文件夾路徑
build_DIR=${SRCROOT}/build
echo "build_DIR=${build_DIR}"
#真機(jī)build生成的頭文件的文件夾路徑
DEVICE_DIR_INCLUDE=${build_DIR}/Release-iphoneos/include/${PROJECT_NAME}
echo "DEVICE_DIR_INCLUDE=${DEVICE_DIR_INCLUDE}"
#真機(jī)build生成的.a文件路徑
DEVICE_DIR_A=${build_DIR}/Release-iphoneos/lib${PROJECT_NAME}.a
echo "DEVICE_DIR_A=${DEVICE_DIR_A}"
#模擬器build生成的.a文件路徑
SIMULATOR_DIR_A=${build_DIR}/Release-iphonesimulator/lib${PROJECT_NAME}.a
echo "SIMULATOR_DIR_A=${SIMULATOR_DIR_A}"
#目標(biāo)文件夾路徑
INSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}
echo "INSTALL_DIR=${INSTALL_DIR}"
#目標(biāo)頭文件文件夾路徑
INSTALL_DIR_Headers=${SRCROOT}/Products/${PROJECT_NAME}/Headers
echo "INSTALL_DIR_Headers=${INSTALL_DIR_Headers}"
#目標(biāo).a路徑
INSTALL_DIR_A=${SRCROOT}/Products/${PROJECT_NAME}/lib${PROJECT_NAME}.a
echo "INSTALL_DIR_A=${INSTALL_DIR_A}"
#判斷build文件夾是否存在,存在則刪除
if [ -d "${build_DIR}" ]
then
rm -rf "${build_DIR}"
fi
#判斷目標(biāo)文件夾是否存在缀蹄,存在則刪除該文件夾
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
#創(chuàng)建目標(biāo)文件夾
mkdir -p "${INSTALL_DIR}"
#build之前clean一下
xcodebuild -target ${target_Name} clean
#模擬器build
xcodebuild -target ${target_Name} -configuration Release -sdk iphonesimulator
#真機(jī)build
xcodebuild -target ${target_Name} -configuration Release -sdk iphoneos
#復(fù)制頭文件到目標(biāo)文件夾
cp -R "${DEVICE_DIR_INCLUDE}" "${INSTALL_DIR_Headers}"
#合成模擬器和真機(jī).a包
lipo -create "${DEVICE_DIR_A}" "${SIMULATOR_DIR_A}" -output "${INSTALL_DIR_A}"
#打開目標(biāo)文件夾
open "${INSTALL_DIR}"
fi