#!/bin/sh export LANG=en_US.UTF-8 # capture ERR signal trap 'exit 2' ERR R(){ echo "\033[31m"$1"\033[0m" } G(){ echo "\033[32m"$1"\033[0m" } P(){ echo "\033[35m"$1"\033[0m" } if [ $# != 1 ] ; then echo 'Invalid parameters, plase input output path' exit; fi PROJECT=`ls .|grep xcodeproj|cut -d. -f1` FRAMEWORK_NAME=${PROJECT} FRAMEWORK_VERSION=1.0.0 FRAMEWORK_CONFIG=Release PRODUCT_DIR=Products if [ -d "$PRODUCT_DIR" ]; then rm -rf $PRODUCT_DIR else mkdir -pv $PRODUCT_DIR fi # Building each architectures echo "Begin Building Release [${FRAMEWORK_NAME}]" buildsilulator(){ xcodebuild -configuration "${FRAMEWORK_CONFIG}" -sdk iphonesimulator -workspace ${FRAMEWORK_NAME}.xcworkspace -scheme "${FRAMEWORK_NAME}" clean xcodebuild OTHER_CFLAGS="-fembed-bitcode" -configuration "${FRAMEWORK_CONFIG}" -sdk iphonesimulator -workspace ${FRAMEWORK_NAME}.xcworkspace -scheme "${FRAMEWORK_NAME}" -derivedDataPath "${PRODUCT_DIR}" DEPLOYMENT_POSTPROCESSING=YES STRIP_STYLE=debugging } buildos(){ xcodebuild -configuration "${FRAMEWORK_CONFIG}" -sdk iphoneos -workspace ${FRAMEWORK_NAME}.xcworkspace -scheme "${FRAMEWORK_NAME}" clean xcodebuild OTHER_CFLAGS="-fembed-bitcode" -configuration "${FRAMEWORK_CONFIG}" -sdk iphoneos -workspace ${FRAMEWORK_NAME}.xcworkspace -scheme "${FRAMEWORK_NAME}" -derivedDataPath "${PRODUCT_DIR}" archive DEPLOYMENT_POSTPROCESSING=YES STRIP_STYLE=debugging } buildsilulator buildos FULL_PRODUCT_PATH=`pwd`/$PRODUCT_DIR DEVICE_FRAMEWORK=$FULL_PRODUCT_PATH/Build/Intermediates/ArchiveIntermediates/${FRAMEWORK_NAME}/BuildProductsPath/Release-iphoneos/${FRAMEWORK_NAME}.framework SIMLULATOR_FRAMEWORK=$FULL_PRODUCT_PATH/Build/Products/${FRAMEWORK_CONFIG}-iphonesimulator/${FRAMEWORK_NAME}.framework echo $DEVICE_FRAMEWORK echo $SIMLULATOR_FRAMEWORK lipo -create "${DEVICE_FRAMEWORK}/${FRAMEWORK_NAME}" "${SIMLULATOR_FRAMEWORK}/${FRAMEWORK_NAME}" -output "${SIMLULATOR_FRAMEWORK}/${FRAMEWORK_NAME}" OUTPUT_FRAMEWORK=${FRAMEWORK_NAME}.framework [ -d "${OUTPUT_FRAMEWORK}" ] && { rm -rf ${OUTPUT_FRAMEWORK} } echo "copy framework binary" cp -rvf ${SIMLULATOR_FRAMEWORK} ${OUTPUT_FRAMEWORK} echo "copy the public headers" find Pods/Headers/Public -name "*.h" -exec cp {} ${OUTPUT_FRAMEWORK}/Headers/ \; if [ -d "${OUTPUT_FRAMEWORK}" ]; then [ -d "${OUTPUT_FRAMEWORK}/${OUTPUT_FRAMEWORK}" ] && { rm -rf ${OUTPUT_FRAMEWORK}/${OUTPUT_FRAMEWORK} } cp -rvf ${OUTPUT_FRAMEWORK} $1 cp .hiveconfig $1 echo "Success!" else echo "Faild!" fi