Before using the "New Build System", we had a build phase script like this:
infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
builddate=`date`
/usr/libexec/PlistBuddy -c "Set :BuildDateString $builddate" "${infoplist}"
The point of this way to write to the plist at runtime without dirtying the project and having to stash the changes. This still works well and perfectly when using the "Legacy Build System".
On the "New Build System", this script does not work. The directory variables and writing to the plist will works but the changes are somehow overwritten.
Is there a way to write to a built plist via the build phase script? If not, is there a way to achieve the goal of writing information only when the application runs without dirtying the local repo.
It looks like that sometimes, under the "New Build System", the
Process Info.plist
step is after all theRun custom scripts
step.So I use script to generate another
custom.plist
at the bundleAs @rpstw points out, any custom build steps will run before the New Build System's
Process .../Info.plist
step.Product > Scheme > Edit Scheme... > Build > Post-actions
If you're going to reference any build system environment variables (e.g.
BUILT_PRODUCTS_DIR
orINFOPLIST_PATH
), make sure you change the Provide build settings from selection.Add your shell script, but remember that if you edit any file in the app bundle (i.e.
Info.plist
), you'll need to re-sign the app. Add this to your post build step: