Modifying Info.plist's CFBundleVersion in Xcode 5 with Asset Library enabled

11,238

Solution 1

Figured this one out, and it was a silly one. Turns out you can just move the script phase to the very end. I didn't even know these were movable, or that it mattered! But by dragging the Run Script phase to the bottom as such, the scripts were able to run and modify things as needed.

Build Phases

Solution 2

I had similar issue once, and here is what finally helped me out:

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${INFOPLIST_FILE}"

(Use INFOPLIST_FILE directly, not $BUILT_PRODUCTS_DIR/$INFOPLIST_PATH)

Hope this could be useful .

Solution 3

I had the same problem, In my case, I had a wrong file path to the XXX-Info.plist file:

Build Settings -> Packaging -> Info.plist File

I changed it it's actual location and start working.

Description to where to change the wrong settings

Solution 4

If your plist file is Preprocessed-Info.plist, then change the value of "Preprocess Info.plist File" (INFOPLIST_PREPROCESS) to "Yes" (true) like this:

this

Solution 5

Search in Build settings for $(SRCROOT) and remove it.

transform it from $(SRCROOT)/TestProject/Info.plist to TestProject/Info.plist

enter image description here

Share:
11,238
SpacePyro
Author by

SpacePyro

UT Austin alum. Programming, videogame, and anime enthusiast. I also love a nice cup of coffee. I'm a Swift / Objective-C guru with enough knowledge of Ruby to live dangerously. I'm also the creator of MyAniList.

Updated on June 25, 2022

Comments

  • SpacePyro
    SpacePyro about 2 years

    With Xcode 5's new Asset Library, adding images and organizing them has never been easier. However, it seems as if it has broken some scripts I use for creating builds.

    I have a script within my Run Script Phase that sets the CFBundleVersion to be the current timestamp within the plist. In the script, I execute this statement:

    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $timestamp" $BUILT_PRODUCTS_DIR/$INFOPLIST_PATH
    

    However, when this gets executed, the following statement displays:

    Set: Entry, ":CFBundleVersion", Does Not Exist
    File Doesn't Exist, Will Create: /Users/SpacePyro/Library/DerivedData/BundleTest-duikdqngfmrovnagrcsvdcuxxstz/Build/Products/Debug-iphoneos/BundleTest.app/Info.plist
    

    It seems like this happens on clean builds. The plist doesn't seem to get generated until midway through the build, presumably due to the Asset Libraries.

    I've also used this command, and while it doesn't throw the error, it still blows away my changes (assume INFO_PLIST="${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/Info"):

    defaults write $INFO_PLIST CFBundleVersion $timestamp
    

    This used to not be the case when I started using the Asset Library to organize my app icons and splash images. Anyone know why this happens? And better yet, is there a workaround to add this value to the plist? I've already tried placing the script in a pre-action build phase, as well as the post-action build phase. I've also tried running the command after the build has completed, but when I try to codesign and package it up, it says that the signature is invalid due to plist modification.

    If no reasonable solution exists, I guess I could always de-migrate from Asset Libraries until I can get my scripts to work.