Skip to content

Instantly share code, notes, and snippets.

@mflint
Created April 5, 2014 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mflint/9999558 to your computer and use it in GitHub Desktop.
Save mflint/9999558 to your computer and use it in GitHub Desktop.
bash script to strip unwanted symbols from an Apple fat-binary library
#!/bin/sh
# this is the name of the problematic lib
FRAMEWORK=ActivityX.framework
LIB=ActivityX
# these are the duplicate symbols
SYMBOLS="AFURLRequestSerialization.o AFHTTPRequestOperationManager.o AFURLSessionManager.o"
# the architectures in the lib
ARCHS=`lipo -info $FRAMEWORK/$LIB | sed -e "s/^.*are: //"`
# this is where the extracted libs will go for every architecture
rm -rf tmp
mkdir tmp
for ARCH in $ARCHS
do
# split the arch from the fat binary
lipo $FRAMEWORK/$LIB -thin $ARCH -output tmp/lib.$ARCH
for SYMBOL in $SYMBOLS
do
# remove symbol from lib
ar -d -sv tmp/lib.$ARCH $SYMBOL
done
done
# resolve the actual location of the library
LIB_PATH=$FRAMEWORK/`readlink $FRAMEWORK/$LIB`
echo $LIB_PATH
# make a replacement fat binary
lipo tmp/* -create -output $LIB_PATH
# and tidy up
rm -rf tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment