iOS在生成framework時需要在真機(jī)下編譯一次并在模擬器下編譯一次
編譯后還需要合并兩個framework?手動進(jìn)行如果一直在調(diào)試會很麻煩
現(xiàn)在給出自動化解決方案:加入編譯腳本(關(guān)于如何打包蘋果framework包我就不做具體描述了)
以JGProgressHUD為例:
1.如下圖1.1所示:在根目錄下新建auto_farmeWork.sh的腳本文件和FrameWork的生成腳本后的輸出文件夾
2.找到bulid Phases戚嗅,新建Run Script Phase,如下圖1.2所示:
3.添加如下圖1.3腳本代碼:
具體代碼:
TDIR=${PROJECT_DIR}FrameWork
cd"${TDIR}"
sh auto_frameWork.sh
4.項目切換到release模式然后分別在模擬器和真機(jī)各運(yùn)行一下,在FrameWork文件夾下就會生成二合一的framework包了连霉,如下圖1.4所示:
具體shell腳本代碼如下:
#!/bin/shbundleID=${PRODUCT_BUNDLE_IDENTIFIER}
CURRENTCONFIG_DEVICE_DIR=${BUILD_DIR}/${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}
JfBuildDir=${BUILD_DIR}
JfExecutablePath=${EXECUTABLE_PATH}
JfExecutableName=${EXECUTABLE_NAME}
JfExecutableFolderPath=${EXECUTABLE_FOLDER_PATH}
echo "JfBuildDir =$JfBuildDir"
echo "JfExecutablePath =$JfExecutablePath"
echo "JfExecutableName =$JfExecutableName"
echo"90-> ${CURRENTCONFIG_DEVICE_DIR}"
cd${JfBuildDir}
framework="SDKTest"
[ -f"$framework"] && rm"$framework"
dire="FrameWork/"
[ -d"$dire"] && rm -rf"$dire"
mkdir"$dire"
if [ -d "Release-iphoneos" ] && [ -d "Release-iphonesimulator" ]; then
echo "composition framework"
lipo -create Release-iphoneos/${JfExecutablePath} Release-iphonesimulator/${JfExecutablePath} -output ${JfExecutableName}
cp -rf Release-iphoneos/* ${dire}
cp -f ${JfExecutableName} ${dire}/${JfExecutableFolderPath}
rm -f ${JfExecutableName}
open ${dire}
fi