Skip to content

Instantly share code, notes, and snippets.

@ko2ic
Last active December 22, 2015 03:06
Show Gist options
  • Save ko2ic/dab2a582a7b41e9bacd2 to your computer and use it in GitHub Desktop.
Save ko2ic/dab2a582a7b41e9bacd2 to your computer and use it in GitHub Desktop.
static ライブラリから不必要な依存ライブラリを削除
#!/bin/sh
archtectureStr=`lipo -info $1 | awk '$0 = substr($0, index($0, "are: ") + 5)'`
archtectures=(`echo $archtectureStr`)
tempFileStr=""
for i in `seq 1 ${#archtectures[@]}`
do
tempFile=$1_${archtectures[$i-1]}
`lipo -thin ${archtectures[$i-1]} $1 -output $tempFile`
deleteFiles=`ar -t $tempFile | grep ${2}`
echo `ar -dv $tempFile $deleteFiles`
tempFileStr=$tempFile" "$tempFileStr
done
echo `lipo -create $tempFileStr -output $1`
`rm -f $tempFileStr`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment