Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9163165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:22:49+00:00 2026-06-17T14:22:49+00:00

Possible Duplicate: Xcode project’s Build number I’m using this script to update CFBundleVersion during

  • 0

Possible Duplicate:
Xcode project’s “Build number”

I’m using this script to update CFBundleVersion during build in Xcode 4.5.2 (app for iOS):

#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

It seems to work fine and every time I build my app “build number” (CFBundleVersion) increases by 1.

The odd behavior happens when I try to retrieve CFBundleVersion programmatically using:

[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]

or

[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]

And this is what I get:

CFBundleVersion 1 -> I get 1
CFBundleVersion 2 -> I get 1 odd
CFBundleVersion 3 -> I get 3
CFBundleVersion 4 -> I get 3 odd
CFBundleVersion 5 -> I get 5
CFBundleVersion 6 -> I get 5 odd
CFBundleVersion 7 -> I get 7
CFBundleVersion 8 -> I get 7 odd
CFBundleVersion 9 -> I get 9
CFBundleVersion 10 -> I get 10
CFBundleVersion 11 -> I get 10 odd
CFBundleVersion 12 -> I get 12
CFBundleVersion 13 -> I get 13
CFBundleVersion 14 -> I get 14
CFBundleVersion 15 -> I get 14 odd
CFBundleVersion 16 -> I get 16
CFBundleVersion 17 -> I get 16 odd
CFBundleVersion 18 -> I get 18
CFBundleVersion 19 -> I get 18 odd
CFBundleVersion 20 -> I get 20
CFBundleVersion 21 -> I get 21
CFBundleVersion 22 -> I get 22
and so on...

Outputs change each time, but the odd behavior persists in simulator and on the device.
If I remove the script and put CFBundleVersion manually in place, everything goes smoothly.

Does someone know why? And how can I fix it?
Thanks!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:22:51+00:00Added an answer on June 17, 2026 at 2:22 pm

    The problem is that Xcode does not check anymore for modified files after the run script has been executed. So even if the run script updates the Info.plist file, Xcode does not copy the updated file into the application bundle.

    As a workaround, you can create an additional target (i.e. an “Aggregate” target) to your project and add the run script to that additional target, instead of your main target.

    The $INFOPLIST_FILE environment variable is not defined for the additional target, but you can use the actual (project relative) path instead, i.e. replace $INFOPLIST_FILE by

    YourMainTarget/YourMainTarget-Info.plist
    

    Then drag the additional target into the “Target Dependencies” of your main target, so that the additional target is always built first.

    EDIT: I just found a more elegant solution here: https://stackoverflow.com/a/11112042/1187415, using a “Pre-action” script instead of an additional target.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Using Git with an existing Xcode project Setting up a git repository
Possible Duplicate: Xcode 4.4.1, iOS 5.1: Xcode cannot run using the selected device My
Possible Duplicate: crashing on ios device while navigation using UIModalTransitionStylePartialCurl in xcode 4 HI
Possible Duplicate: iOS App crashing before entering main() with Xcode 4.2 & iOS 5
Possible Duplicate: Is it possible to target older iOS versions when using Xcode 4.2
Possible Duplicate: Is it possible to target older iOS versions when using Xcode 4.2
Possible Duplicate: NSLayoutConstraint crashes ViewController recently after updating Xcode my app now fails to
Possible Duplicate: How do I rename a project in Xcode? Hi I am tying
Possible Duplicate: iOS 6 Xcode 4.5 unsupported architecture armv7s I'm going to upload my
Possible Duplicate: iOS 6 Xcode 4.5 unsupported architecture armv7s I am planning to submit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.