简体   繁体   English

更改除应用程序图标构建阶段xcode以外的所有图像名称

[英]Change all image names except app icon build phase xcode

I am working on an ipad project that requires changing the formatting of image names for the project in a run script build phase in xcode 5. I am running the following script: 我正在开发一个ipad项目,该项目需要在xcode 5的运行脚本构建阶段中更改该项目的图像名称格式。我正在运行以下脚本:

for f in ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}/*.png
do
fileName=${f:${#BUILT_PRODUCTS_DIR}+${#FULL_PRODUCT_NAME}+2:${#f}}
lc='echo $fileName | tr "[:upper:]" "[:lower:]"
lc=`echo $lc | tr - _`
lc=${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}/${lc}
mv $f $lc
done

The script finds all images in the bundle and makes the names all lowercase and changes uses of '-' to '_'. 该脚本查找捆绑软件中的所有图像,并将名称全部小写,并将“-”的用法更改为“ _”。 This works perfectly for my situation, however it is also changing the name of the app icon and launch images resulting in them not being used by the app. 这完全适合我的情况,但是它也在更改应用程序图标的名称并启动图像,从而导致应用程序不使用它们。

What I want is either a way to have the script skip the app icon and launch images, or a way to simply change the names of the images in xcode so that the resulting name from the script is the accurate name. 我想要的是一种使脚本跳过应用程序图标并启动图像的方法,或者是一种简单地更改xcode中图像名称的方法,以使脚本生成的名称为准确名称。

The biggest issue I have had with simply manually changing the names is that I cannot find how xcode is controlling the naming system because the names I have for the images are already in the proper format so xcode must be creating its own names for the icon and launch images. 我只是手动更改名称而遇到的最大问题是,我找不到xcode如何控制命名系统,因为图像的名称已经采用了正确的格式,因此xcode必须为图标创建自己的名称,并且启动图像。

Thanks 谢谢

Assuming standard naming, and that you don't also have your own files that begin with "Icon" or "Default", you could do this. 假设使用标准命名,并且您也没有以“ Icon”或“ Default”开头的文件,则可以执行此操作。 If you have your own images that match that pattern, you will need to add special cases below, or specifically target all the various icon and launch image files. 如果您拥有与该模式匹配的图像,则需要在下面添加特殊情况,或专门针对所有各种图标并启动图像文件。

for f in ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}/*.png
do
    BASENAME=$(basename $f)
    if [[ ${BASENAME} == Icon* ]] || [[ ${BASENAME} == Default* ]] ;
    then
        echo "App icon or launch image, leaving file alone"
    else
        fileName=${f:${#BUILT_PRODUCTS_DIR}+${#FULL_PRODUCT_NAME}+2:${#f}}
        lc=`echo $fileName | tr "[:upper:]" "[:lower:]"`
        lc=`echo $lc | tr - _`
        lc=${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}/${lc}
        mv "$f" "$lc"
    fi
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM