Created
December 3, 2013 00:23
-
-
Save skabber/7761735 to your computer and use it in GitHub Desktop.
Strip a symbol from a fat library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage ./strip.sh libGoogleAdMobAds.a GAD_GTMStringEncoding.o | |
LIBRARY=$1 | |
SYMBOL=$2 | |
mkdir -p ./archs/ | |
LIPO_OUTPUT=($(lipo -info $1)) | |
ARCHS=() | |
ASSEMBLE_COMMAND="lipo" | |
I=1 | |
TOTAL=${#LIPO_OUTPUT[@]} | |
for aString in ${LIPO_OUTPUT[@]} | |
do | |
ITEM=${LIPO_OUTPUT[$TOTAL-$I]} | |
if [[ $ITEM =~ .*: ]] ; then | |
break | |
fi | |
ARCH=$ITEM | |
ARCHS+=($ARCH) | |
I=$[$I+1] | |
# Thin out each arch from the library | |
lipo $LIBRARY -thin $ARCH -output ./archs/$ARCH.a | |
# Fix the permissions | |
chmod 755 ./archs/$ARCH.a | |
# Remove the offending symbol from each arch | |
ar -d ./archs/$ARCH.a $SYMBOL | |
done | |
for ARCH in ${ARCHS[@]} | |
do | |
ASSEMBLE_COMMAND+=" ./archs/$ARCH.a" | |
done | |
ASSEMBLE_COMMAND+=" -create -output $LIBRARY.stripped" | |
eval $ASSEMBLE_COMMAND |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment