5

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.

enter image description here

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!

enter image description here

From terminal, result is correct:

alp$ BUILD_DATE=`date "+%B %Y"`
alp$ echo $BUILD_DATE
March 2013
alp$ 

but in Xcode no!

enter image description here

How can i fix this?

elp
  • 8,021
  • 7
  • 61
  • 120

1 Answers1

3

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}"
Community
  • 1
  • 1
trojanfoe
  • 120,358
  • 21
  • 212
  • 242