您好,登录后才能下订单哦!
目的很简单,就是从ipa包中抽取图片资源,然后按照ipa中的目录结构存放.
#!/bin/sh
#usage:extra-p_w_picpath-from-ipa <ipa-file>|<Payload-dir> <target-dir>
echo $#
if [[ $# != 2 ]]; then
echo "extra-p_w_picpath-from-ipa <ipa-file>|<Payload-dir> <target-dir>"
exit 1
fi
IPA_FILE=$1
TARGET_DIR=$2
if [[ -f "$IPA_FILE" ]]; then
echo "解压ipa包到临时目录"
IPA_DIR="/tmp/extra-p_w_picpath-from-ipa/temp/`date "+%Y%m%d-%H%M%S"`"
echo "temp-dir: " $IPA_DIR
#rm -rf $IPA_DIR
mkdir -p $IPA_DIR
echo "unzip $IPA_FILE begin ..."
unzip -q "$IPA_FILE" -d "$IPA_DIR"
if [[ $? != 0 ]]; then
echo "unzip $IPA_FILE failed"
exit 2
else
echo "unzip $IPA_FILE successed"
fi
# 定位到*.app目录
IPA_DIR="$IPA_DIR/""Payload/""`ls "$IPA_DIR/"Payload`"
else
IPA_DIR=$IPA_FILE
fi
copy_p_w_picpath()
{
#echo "begin copy p_w_picpath"
R="$1"
D="$2"
S="$3"
#echo "建立和ipa包相同层次的目录机构"
T=${S/$R/$D}
mkdir -p `dirname $T`
cp -rf $S $T
if [[ $T =~ \.png$ ]]; then
#echo "利用PNGCrush还原被优化的png图片"
mv $T $T.orign
xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations -q $T.orign $T
if [[ $? != 0 ]]; then
echo "revert failed: " $T.orgin
else
rm $T.orign
fi
fi
#echo "end copy p_w_picpath"
}
# 导出函数 供下面的find方法使用
export -f copy_p_w_picpath
echo "copy jpg p_w_picpath"
find "$IPA_DIR" -name "*.jpg" -exec sh -c "copy_p_w_picpath $IPA_DIR $TARGET_DIR {}" \;
echo "process png p_w_picpath"
find "$IPA_DIR" -name "*.png" -exec sh -c "copy_p_w_picpath $IPA_DIR $TARGET_DIR {}" \;
echo "finished"
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。