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

后端 未结 3 709
小蘑菇
小蘑菇 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条回答
  •  旧时难觅i
    2020-12-24 15:36

    Ahhhh, I should have spent another 30 minutes (on top of the 2 hours I had already wasted) and looked at the answers for this question before posting my own:

    Insert Subversion revision number in Xcode

    This post-action script does the trick and works for me:

    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
    

    As you can see, it's doing a bit of a hack there (adding it if it doesn't exist; setting it right afterwards).

    If anyone can suggest a solution using the "defaults write" method above (which I think might be better supported than "PlistBuddy"), I'd be thrilled to find out (and of course I'll accept and use that superior answer, too).

提交回复
热议问题