Skip to content

Instantly share code, notes, and snippets.

@neonichu
Created January 23, 2012 12:35
Show Gist options
  • Save neonichu/1662881 to your computer and use it in GitHub Desktop.
Save neonichu/1662881 to your computer and use it in GitHub Desktop.
Strip debug symbol from universal static libraries (tested for iOS only)
#!/bin/sh
#
## Strip debug symbol from universal static libraries
#
if [ -z "$1" ]
then
echo "$0 library"
exit 1
fi
file "$1"|grep 'ar archive random library' >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo "$1: not a static library"
exit 1
fi
TMP=`mktemp -d /tmp/tmp.XXXXXX`
for arch in `file "$1"|grep 'architecture '|sed 's/.*(for architecture \(.*\)).*/\1/'`
do
lipo "$1" -thin $arch -output $TMP/libfoo-$arch-unstripped.a
strip -S -x -o $TMP/libfoo-$arch.a -r $TMP/libfoo-$arch-unstripped.a
done
rm -f $TMP/*-unstripped.a
lipo -create -output "$1-stripped" $TMP/*.a
rm -f $TMP/*.a
rmdir $TMP
@navaneet
Copy link

I tried executing this script on my mac but I am getting some strange error when I do the following in the terminal

sh strip-lib.sh ./myLib.a

fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't open input file: /tmp/tmp.Wd6iUM/*.a (No such file or directory)

Can you please let me know if there is anything I need to change in the script or if I am missing something

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