Version and build detailed in IOS project _ios

Source: Internet
Author: User

Version and build in the IOS project

Version's key in the plist file is "cfbundleshortversionstring", which identifies the release version number of the application and is consistent with the version number on the App store. The version number of this version is a string consisting of three separate integers. The first integer represents a substantially modified version, such as a revision that implements a new feature or significant change. The second integer represents the revision, which achieves a more prominent feature. The third integer represents the maintenance version

The key to build in the plist file is "Cfbundleversion", the build number that marks (publishes or is not published). This is a monotonically increasing string, consisting of one or more divided integers.

The above two versions can be obtained in the following ways:

Nsdictionary *infodictionary = [[NSBundle mainbundle] infodictionary]; 
  
App version 
nsstring *app_version = [infodictionary objectforkey:@ "cfbundleshortversionstring"]; 
  
App build version 
nsstring *app_build = [infodictionary objectforkey:@ "cfbundleversion"]; 

Scripting to automatically grow the build version number after archive

If we want to grow automatically after the archive, we can use the run script to Xcode, and the steps are

    1. Select target for the item and click "Build Phases"
    2. Click on the "Add Build Phrase" in the lower-right corner and select "Add Run Script" to produce a new run script item
    3. Drag the newly generated run script item to the top
    4. Click on the item, copy the following shell code in, the code from here, as shown in the following figure

if [$CONFIGURATION = release]; Then 
  echo "bumping build number ..." 
  Plist=${project_dir}/${infoplist_file} #increment The build number 
 
  ( IE to 116) 
  buildnum=$ (/usr/libexec/plistbuddy-c "Print cfbundleversion" "${plist}") 
  if [["${buildnum}" = " " ]]; Then 
    echo "No build number in $plist" 
    exit 2 
  fi 
 
  buildnum=$ (expr $buildnum + 1) 
  /usr/libexec/ Plistbuddy-c "Set cfbundleversion $buildnum" "${plist}" 
  echo "bumped build number to $buildnum" 
 
else 
  echo $CONFIGURATION "Build-not bumping build number." 
Fi 

What this shell script means is that if the current configuration is release (archive when the value is release, and run directly on the emulator is debug), the build value is set to the current build value of +1, otherwise nothing will be done.

That way you'll see the build number automatically adds 1 when you build it, and you want to see the information that comes out of the build, and you can view the log from the latest build with the view-> Navigators-> log.

Thank you for reading, I hope to help you, thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.