Created
April 5, 2014 23:45
-
-
Save mflint/9999558 to your computer and use it in GitHub Desktop.
bash script to strip unwanted symbols from an Apple fat-binary library
This file contains hidden or 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/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