• xib文件转NIb文件


    xib文件转NIb文件

    使用方法:sh ./nib.sh ./

    #!/bin/bash
    
    # --------------------------------------------------------------------------- #
    # 获取文件名后缀
    # Parameter1: 文件名
    # output: Yes
    # return: None
    # --------------------------------------------------------------------------- #
    function FileSuffix() {
        local filename="$1"
        if [ -n "$filename" ]; then
            echo "${filename##*.}"
        fi
    }
    
    # --------------------------------------------------------------------------- #
    # 获取文件名前缀
    # Parameter1: 文件名
    # output: Yes
    # return: None
    # --------------------------------------------------------------------------- #
    function FilePrefix() {
        local filename="$1"
        if [ -n "$filename" ]; then
            echo "${filename%.*}"
        fi
    }
    
    # --------------------------------------------------------------------------- #
    # 判断文件后缀是否是指定后缀
    # Parameter1: 文件名
    # parameter2: 后缀名
    # output: None
    # return: 0: 表示文件后缀是指定后缀;1: 表示文件后缀不是指定后缀
    # --------------------------------------------------------------------------- #
    function IsSuffix() {
        local filename="$1"
        local suffix="$2"
        if [ "$(FileSuffix ${filename})" = "$suffix" ]; then
            return 0
        else
            return 1
        fi
    }
    
    # --------------------------------------------------------------------------- #
    # 将xib编译成nib文件
    # --------------------------------------------------------------------------- #
    function transitionToNib(){
        ibtool --errors --warnings --output-format human-readable-text --compile ibtool --errors --warnings --output-format human-readable-text --compile $1 $2
    
    }
    
    # --------------------------------------------------------------------------- #
    #处理输入的参数 并编译成nib
    # --------------------------------------------------------------------------- #
    function handlFile(){
    	ORIGIN=$1
    	# echo $1
    
    	XIBFILE=${ORIGIN##*/}
    	# echo "$XIBFILE xib文件"
    
    	IsSuffix ${XIBFILE} "xib"
    	ret=$?
    
    	if [  $ret -eq 0 ]; then
        	echo "the suffix of the ${file} is xib"
        	FILENAME="${ORIGIN%.*}"
    		NIBFILEDIR=$FILENAME".nib"
        	NIBFILE=${NIBFILEDIR##*/}
    
    		echo "$FILENAME file名"
    		echo "$NIBFILE nib文件"
    
    		transitionToNib $NIBFILE $XIBFILE
        else
        	echo "the suffix of the ${XIBFILE} is not xib"
    	fi
    
    
    }
    
    #循环目录,将每个xib编译成nib
    function scandir() {
        local cur_dir parent_dir workdir
        workdir=$1
        cd ${workdir}
        if [ ${workdir} = "/" ]
        then
            cur_dir=""
        else
            cur_dir=$(pwd)
        fi
    
        for dirlist in $(ls ${cur_dir})
        do
            if test -d ${dirlist};then
                cd ${dirlist}
                scandir ${cur_dir}/${dirlist}
                cd ..
            else
                echo "${cur_dir}/${dirlist} 子文件"
    
                handlFile ${cur_dir}/${dirlist}
    
            fi
        done
    }
    
    
    echo `basename $0` is in `pwd`
    #return
    
    #判断是否有输入参数 需输入一个xib文件 或 一个只包含xib的文件 注意,xib文件名不能为空,否则不会被编译成nib
    if [ ! -n "$1" ] ;then
        echo "you have not input a xibfile or directory of xibfile!"
        return
    # else
        # echo "the word you input is $1"
    fi
    
    
    
    #判断是文件还是文件夹
    if test -d $1
    then
    
    	# echo "you input  a directory"
    
        scandir $1
    
        exit 1
    
    elif test -f $1
    then
        # echo "you input a file "
    
        handlFile $1
        
        exit 1
    else
        echo "the Directory isn't exist which you input,pls input a new one!!"
        exit 1
    fi
    

      

  • 相关阅读:
    ASP.NET MVC实现通用设置
    C# Redis的操作
    Jquery Ajax向服务端传递数组参数值
    ASP.NET 通过配置hiddenSegment禁止目录下资源通过Url形式访问
    Jquery组织Form表单提交之Form submission canceled because the form is not connected
    Entity Framework工具POCO Code First Generator的使用
    ASP.NET MVC 5搭建自己的视图基架 (CodeTemplate)
    Jquery Ajax 提交json数据
    使用Reflector反编译并提取源代码
    ASP.NET MVC下Bundle的使用
  • 原文地址:https://www.cnblogs.com/nuanshou/p/15392774.html
Copyright © 2020-2023  润新知