一个sh脚本每次build的时候动态修改info.plist文件 达到动态更改版本号的目的 但是估计是因为缓存的缘故 每次只有clean之后再运行才会修改成功 看script执行的log 好像是先修改之后然后xcode去copy了一份旧的plist给覆盖了。。。 但是clean之后却没有这个copy操作 这是为什么 ????
提出临时解决办法 删掉当前app目录下的plist的文件 跑过去修改原plist文件 哈哈哈 每次强迫xcode去copy
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"