script 修改 plist遇到的问题
Posted rexzhao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了script 修改 plist遇到的问题相关的知识,希望对你有一定的参考价值。
一个sh脚本每次build的时候动态修改info.plist文件 达到动态更改版本号的目的 但是估计是因为缓存的缘故 每次只有clean之后再运行才会修改成功 看script执行的log 好像是先修改之后然后xcode去copy了一份旧的plist给覆盖了。。。 但是clean之后却没有这个copy操作 这是为什么 ????
提出临时解决办法 删掉当前app目录下的plist的文件 跑过去修改原plist文件 哈哈哈 每次强迫xcode去copy
echo ${SRCROOT}
FILE_PATH=${SRCROOT}/../version.json
info_plist="$CONFIGURATION_BUILD_DIR/$PRODUCT_NAME.app/Info.plist"
echo ${info_plist}
echo $info_plist
echo "Removing Info.plist from build dir in order to force rebuild of it and reading of correct xcconfig variables, plist path $info_plist"
rm "$info_plist"
publicNet=$(cat $FILE_PATH | jq .PublicNet)
vCode=$(cat $FILE_PATH | jq .ios.vCode)
vName=$(cat $FILE_PATH | jq .IOS.vName | sed ‘s/"//g‘)
if [ "$publicNet" == "false" ];then
deployKey=$(cat $FILE_PATH | jq .IOS.CodePushDeploymentKey_staging | sed ‘s/"//g‘)
elif [ "$publicNet" == "true" ];then
deployKey=$(cat $FILE_PATH | jq .IOS.CodePushDeploymentKey_production | sed ‘s/"//g‘)
else
deployKey=$(cat $FILE_PATH | jq .IOS.CodePushDeploymentKey_staging | sed ‘s/"//g‘)
fi
echo ${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}
echo ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}
_publicNet=$(/usr/libexec/PlistBuddy -c "Print :PublicNet" "${SRCROOT}/$TARGETNAME/Info.plist")
_vName=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${SRCROOT}/$TARGETNAME/Info.plist")
_vCode=$(/usr/libexec/PlistBuddy -c "Print :VersionCode" "${SRCROOT}/$TARGETNAME/Info.plist")
_vDeployKey=$(/usr/libexec/PlistBuddy -c "Print :CodePushDeploymentKey" "${SRCROOT}/$TARGETNAME/Info.plist")
echo "current PublicNet value is : $_publicNet"
echo "current version name is : $_vName"
echo "current version code is : $_vCode"
echo "current deploy key is : $_vDeployKey"
FILE_PATH=${SRCROOT}/../version.json
info_plist="$CONFIGURATION_BUILD_DIR/$PRODUCT_NAME.app/Info.plist"
echo ${info_plist}
echo $info_plist
echo "Removing Info.plist from build dir in order to force rebuild of it and reading of correct xcconfig variables, plist path $info_plist"
rm "$info_plist"
publicNet=$(cat $FILE_PATH | jq .PublicNet)
vCode=$(cat $FILE_PATH | jq .ios.vCode)
vName=$(cat $FILE_PATH | jq .IOS.vName | sed ‘s/"//g‘)
if [ "$publicNet" == "false" ];then
deployKey=$(cat $FILE_PATH | jq .IOS.CodePushDeploymentKey_staging | sed ‘s/"//g‘)
elif [ "$publicNet" == "true" ];then
deployKey=$(cat $FILE_PATH | jq .IOS.CodePushDeploymentKey_production | sed ‘s/"//g‘)
else
deployKey=$(cat $FILE_PATH | jq .IOS.CodePushDeploymentKey_staging | sed ‘s/"//g‘)
fi
echo ${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}
echo ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}
_publicNet=$(/usr/libexec/PlistBuddy -c "Print :PublicNet" "${SRCROOT}/$TARGETNAME/Info.plist")
_vName=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${SRCROOT}/$TARGETNAME/Info.plist")
_vCode=$(/usr/libexec/PlistBuddy -c "Print :VersionCode" "${SRCROOT}/$TARGETNAME/Info.plist")
_vDeployKey=$(/usr/libexec/PlistBuddy -c "Print :CodePushDeploymentKey" "${SRCROOT}/$TARGETNAME/Info.plist")
echo "current PublicNet value is : $_publicNet"
echo "current version name is : $_vName"
echo "current version code is : $_vCode"
echo "current deploy key is : $_vDeployKey"
以上是关于script 修改 plist遇到的问题的主要内容,如果未能解决你的问题,请参考以下文章
我在统一使用firebase时遇到问题,无法找到google-services.json或GoogleService-info.plist文件