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

5

16

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.

Incardination answered 3/10, 2013 at 16:57 Comment(0)
I
14

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

Incardination answered 28/10, 2013 at 15:24 Comment(1)
I moved my main app's Run script phase after Copy Bundle Resources' but before 'Embed App Extensions and Embed Watch Content.Leech
A
21

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 .

Aridatha answered 5/12, 2017 at 0:12 Comment(0)
I
14

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

Incardination answered 28/10, 2013 at 15:24 Comment(1)
I moved my main app's Run script phase after Copy Bundle Resources' but before 'Embed App Extensions and Embed Watch Content.Leech
V
13

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

Valonia answered 7/7, 2014 at 22:1 Comment(1)
Xcode ask me to select a info.plist. After i did it, the path is a full path, which means sh cannot find the info.plist when invoked. So, change it to a relative path.Yahiya
N
2

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

Nataline answered 12/11, 2017 at 11:21 Comment(0)
S
1

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

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

enter image description here

Schnorr answered 6/3, 2019 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.