Insert Subversion revision number in Xcode

后端 未结 7 1634
花落未央
花落未央 2020-11-30 18:29

I would like to insert the current Subversion revision number (as reported by svnversion) into my Xcode project. I managed to insert the revision number into th

7条回答
  •  一个人的身影
    2020-11-30 19:07

    There's a much simpler solution: using PlistBuddy, included at /usr/libexec/PlistBuddy in Leopard. See my answer to a related SO question for details.

    PlistBuddy can be used in a Run Script build phase from within Xcode, and can be used to only affect the processed plist file. Just put it after the Copy Resources phase, and you don't even have to clean the target for it to run each time. You don't even have to print the value to a header file and make SVN ignore it, either.

    echo -n ${TARGET_BUILD_DIR}/${INFOPLIST_PATH} \
        | xargs -0 /usr/libexec/PlistBuddy -c "Set :CFBundleVersion `svnversion -n`"
    

    Assuming you add the build phase before code signing occurs, your plist should be signed with the substituted value.

提交回复
热议问题