Tutorial on tracking compilation times in XCode

Source: Internet
Author: User

XCodeTrackingCompileThe number of times instance tutorial is the content to be introduced in this article. This article is suitable for friends who work on projects separately, sometimes you want to track how many times your project has been edited, XCode/compiled, run, and tested. When you develop one or two programs, if you have the tracking data, you may get a relatively obvious data. How long does it take for you to make good software.

Your time is not infinite. It is important to know how much time you have spent doing one thing. The following describes how to track your project by adding an automatic growth script to the project. The script will generate a. xcconfig file. We can use it to directly implement this project.CompileThe number of times is displayed in the "about" dialog box.
 
Some data in your project
 
I first used this technique through Laugh mancoachina. Note: you will know where the smiling face came from when you read the shells.) But I didn't start using this method before version 0.5.

After using Laugh Man, I started to use SunFlower. This time, I started tracking and compiling data from the very beginning of the project. The following is the tracking data from version 0.1 to version 0.9.

I found this data very useful. This is because I can determine the differences between the lines of code and what I modified in that version. On the one hand, I can determine how much I have paid for the promotion of publishing books and whether it is really useful. At the same time, I can help me estimate whether my work ability has been improved.


 
You may notice that the above data is generated through SunFlower, and you will find that versions 0.5 and 0.8 are frequently compiled. In this way, I know why these two versions have been compiled so many times. For example, in version 0.8, I introduced the scroll bar of the iTunes style, which took me a lot of work to complete it.

Automatically add Shell scripts with version numbers
 
The first thing we need is to automatically increase the number of times we compile. The following script can help us do this. It requires a parameter to save the current number of compilations. This allows us to use the same script to manage multiple projects.

 
 
  1. #!/bin/bash #   
  2. # buildIncrementer     
  3. #  — a simple script to increment the    
  4. #      build number through Xcode # if [ -e "$1" ] then     
  5. echo " do nothing" > /dev/nullelse     
  6. # creat an empty file   touch  
  7. $1 fi     
  8. #increment the build number read number  < $1 let number++echo $number echo $number >   
  9. $1  

I saved this script to the bin directory in my main directory and named it buildIncrementer. You can also save the script to your computer and get your favorite name.
 
Add the script to the Project
 
To use this script in XCode, we need to add a run script phase in the project ). Right-click the project you want to use and choose Add> New Build Phase> New Run Script Build Phase.
 
Next, select Get Info in the newly created Build Phase and modify the script to make it look like the following:

The script is automatically executed when you run the program in XCode. The script automatically creates the. xcconfig version file in your project directory. You can view the version. xcconfig file in the text editor. The content is probably:

 
 
  1. “CURRENT_PROJECT_VERSION = 1” 

Add the number of compilations in the dialog box

We get the number of compilations. It would be nice to add this number in the dialog box. The first thing we need to do is to add the version. xcconfig file to the project.

When you add the automatically generated. xcconfig file, you need to modify the project compilation settings so that the project will be compiled based on that file. Select "Get Info" in the project, and then select Build. Set the configuration to "All deployments" and select version in the Based On drop-down box ..

Finally, edit the info. plist file. In this way, CFBundleVersion uses the value $ {CURRENT_PROJECT_VERSION} and adds a cfbundle‑versionstring.

 
 
  1. <key>CFBundleShortVersionString</key> <string>0.1</string> <key>CFBundleVersion</key> <string>${CURRENT_PROJECT_VERSION}</string>  

In addition, it is very important to remind you that you must clear the project once, and the latest version number will be displayed in the relevant dialog box. This is because XCode will regenerate the info. plist file only when necessary.

If you do not set it, you can download the example project that contains the content described above.

Summary:XCodeTrackingCompileI hope this article will help you!

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.