how to get XCode to add build date & time to Info.plist file

后端 未结 3 708
小蘑菇
小蘑菇 2020-12-24 14:48

Finally... after a couple years of watching and a month of participating, I have a chance to ask you guys a question of my own.

My boss doesn\'t trust me (or any p

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-24 15:31

    The code in Michael's answer is incorrect or no longer up to date. The version below fixes an error in the set syntax and also supports build paths with spaces in them.

    infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
    builddate=`date`
    if [[ -n "$builddate" ]]; then
        # if BuildDateString doesn't exist, add it
        /usr/libexec/PlistBuddy -c "Add :BuildDateString string $builddate" "${infoplist}"
        # and if BuildDateString already existed, update it
        /usr/libexec/PlistBuddy -c "Set :BuildDateString $builddate" "${infoplist}"
    fi
    

    Note: This change was submitted as an edit but got rejected and I don't yet have enough reputation to post a comment on his answer...

提交回复
热议问题