Skip to content

Instantly share code, notes, and snippets.

@tomersh
Last active August 22, 2016 18:31
Show Gist options
  • Save tomersh/083e79fee934c157cf4ade8b953bf36c to your computer and use it in GitHub Desktop.
Save tomersh/083e79fee934c157cf4ade8b953bf36c to your computer and use it in GitHub Desktop.
Pre-Cache pods
PODS_CHECKSUM=$( md5 -q ${PROJECT_DIR}/Podfile.lock )
CACHED_CHECKSUM=$( cat ${PROJECT_DIR}/fatCache/checksum )
if [ $PODS_CHECKSUM != $CACHED_CHECKSUM ]
then
echo error: pod files are stale. Please run make pod-install
exit 1
fi
#!/bin/sh
: ${CURRENT_PATH:=.}
: ${BUILD_DIR:=${CURRENT_PATH}/build}
: ${LIB_CACHE_DIR:=${CURRENT_PATH}/fatCache}
: ${WORKSPACE:=$( find ${CURRENT_PATH} -maxdepth 1 -name *.xcworkspace )}
function buildPodLibraries {
echo building ${1} for devices.
xctool build -sdk iphoneos "CLANG_ENABLE_MODULES=YES" -project ${CURRENT_PATH}/Pods/Pods.xcodeproj -scheme Pods-${1} -configuration Debug -derivedDataPath ${BUILD_DIR}
xctool build -sdk iphoneos "DEBUG_INFORMATION_FORMAT=DWARF with dSYM" "CLANG_ENABLE_MODULES=YES" -project ${CURRENT_PATH}/Pods/Pods.xcodeproj -scheme Pods-${1} -configuration Release -derivedDataPath ${BUILD_DIR}
echo building ${1} for simulator.
xctool build -sdk iphonesimulator "ONLY_ACTIVE_ARCH=NO ARCHS=i386 x86_64" "VALID_ARCHS=i386 x86_64" "CLANG_ENABLE_MODULES=YES" -project ${CURRENT_PATH}/Pods/Pods.xcodeproj -scheme Pods-${1} -configuration Debug -derivedDataPath ${BUILD_DIR}
}
cd ${CURRENT_PATH}
pod install
sed -i '' '/libPods-.*.a in Frameworks/d' ${WORKSPACE}.xcodeproj/project.pbxproj
rm -rf ${BUILD_DIR}
rm -f ${LIB_CACHE_DIR}/Debug/*
rm -f ${LIB_CACHE_DIR}/Release/*
mkdir -p ${BUILD_DIR}
mkdir -p ${LIB_CACHE_DIR}/Debug
mkdir -p ${LIB_CACHE_DIR}/Release
for TARGET_NAME in $( grep -Eo --regexp="^\s*target.* do" ${CURRENT_PATH}/Podfile | grep -Eo --regexp="(:[^ ]+\s)|('.*')" | sed -ne 's,^.\(.*\).$,\1,p' ); do
buildPodLibraries $TARGET_NAME;
done
echo lipo binaries together
#libPod-xxx.a; - debug
for LIBRARY_NAME in $( ls -1 ${BUILD_DIR}/Debug-iphoneos/*.a | tr '\n' '\0' | xargs -0 -n 1 basename ); do
lipo -output ${LIB_CACHE_DIR}/Debug/${LIBRARY_NAME} -create ${BUILD_DIR}/Debug-iphoneos/${LIBRARY_NAME} ${BUILD_DIR}/Debug-iphonesimulator/${LIBRARY_NAME};
done
#nested .a libs - debug
for LIBRARY_NAME in $( ls -1d ${BUILD_DIR}/Debug-iphoneos/*/ | tr '\n' '\0' | xargs -0 -n 1 basename ); do
lipo -output ${LIB_CACHE_DIR}/Debug/lib${LIBRARY_NAME}.a -create ${BUILD_DIR}/Debug-iphoneos/${LIBRARY_NAME}/lib${LIBRARY_NAME}.a ${BUILD_DIR}/Debug-iphonesimulator/${LIBRARY_NAME}/lib${LIBRARY_NAME}.a;
done
#libPod-xxx.a; - release
cp ${BUILD_DIR}/Release-iphoneos/*.a ${LIB_CACHE_DIR}/Release/
#nested .a libs - release
for LIBRARY_NAME in $( ls -1d ${BUILD_DIR}/Release-iphoneos/*/ | tr '\n' '\0' | xargs -0 -n 1 basename ); do
cp ${BUILD_DIR}/Release-iphoneos/${LIBRARY_NAME}/lib${LIBRARY_NAME}.a ${LIB_CACHE_DIR}/Release/
done
md5 -q ${CURRENT_PATH}/Podfile.lock > ${LIB_CACHE_DIR}/checksum
@tomersh
Copy link
Author

tomersh commented Aug 21, 2016

Add $(PROJECT_DIR)/fatCache/Debug or $(PROJECT_DIR)/fatCache/Release to Library search path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment