Add DATE to Xcode xcconfig file

ios, iphone, objective-c, xcode

Solution

You cannot get the build date using the backtick command as the `.xcconfig` file is not interpreted as a shell script.

Your best bet is to use a similar approach the Bump Build Number script in this SO question (that I asked a while back), which provides a solution for using an external build script to update the `.plist` file.

For example:

#!/bin/sh

if [ $# -ne 1 ]; then
    echo usage: $0 plist-file
    exit 1
fi

plist="$1"
build_date=$(date "+%B %Y")

/usr/libexec/Plistbuddy -c "Set BUILD_DATE \"$build_date\"" "$plist"

and invoke it from the Xcode Build Script using something like:

"${PROJECT_DIR}/tools/set_build_date.sh" "${PROJECT_DIR}/${INFOPLIST_FILE}"

Problem

I have an Xcode config file, `Config.xcconfig` that contains this row only: ``` BUILD_DATE=`date "+%B %Y"` ``` I added this configuration to project in correct way, i hope. I want to use the content of BUILD_DATE variable in the `Application-info.plist` file. How? I tried get value using `${BUILD_DATE}` but result is the string ``date "+%B %Y"` not the value! From terminal, result is correct: ``` alp$ BUILD_DATE=`date "+%B %Y"` alp$ echo $BUILD_DATE March 2013 alp$ ``` but in Xcode no! How can i fix this?

Original source

Related problems