skip to Main Content

I’m trying to add a value to my Info.plist inside a Build Phase Run Script:

/usr/libexec/PlistBuddy -c "Add :BuildDate date `date`" "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"

# For debugging:
cat "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}" | grep BuildDate

This works (as proven by the cat), but it seems the result is almost immediately overwritten afterwards, by some other Xcode build step.

Is it simply not possible to modify the Info.plist in the Build Phase? I’ve seen numerous suggestions around the web to do exactly that.

2

Answers


  1. Chosen as BEST ANSWER

    So I never did really discover exactly why this doesn't work for me but does for others. However, I did come across a post which resolved the issue for me. The solution is to add the Info.plist file as an input file in your Build Phase.

    ${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}

    Xcode config screenshot


  2. I assume you’re trying to modify the Info.plist (and not a plist.info as I don’t know what that is).

    It’s absolutely possible to create, modify, or delete the Info.plist during the Build Phase. However, you need to do so before the build process needs to make use of Info.plist. The exact timing of this varies, but the earlier the better – I’d recommend doing so right after the Dependencies step.

    I have a sample Xcode project that does this for a macOS app and a macOS Command Line Tool. It’s considerably more complicated than what you’re likely trying to do, but it might be helpful to take a look and see how it’s configured.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search