The best Xcode version generation technology, xcode version

Source: Internet
Author: User

The best Xcode version generation technology, xcode version

In bloglovin, we use the automatically generated version number to set Xcode so that the current version number is on the active branch of Git.

Number of submissions. It has been working normally, but our technology is not smooth sailing.

Bad old method

We use a technology called "Cocoa is my Girlfriend"1. A Post published by a netizen is really unavailable.

Excuse me. It works as follows:

1. Run a script to get the Git commit count and output it to a file named "infoplistwhatever. h ".

Is not important.

2. Select build Setting in Target in Xcode and support "Preprocess Info. plist" in Packaging settings

File, and set the value of "Info. plist Preprocessor Prefix File" to the File name in Step 1.

3. The value of the git commit count in the "infoplistwhatever. h" file in Setp1 or other values that can achieve this effect,

Use it as the value of the pre-processing variable custom_build_number.

4. Use custom_build_number in Xcode Info. plist to replace the current version number.

Although this technology works properly, it has several very annoying disadvantages:

1. Every time the changed number is submitted, the generated Git will be corrupted.

2. If you do not want to dirty Git, you must ignore "Preprocess Info. plist File ".

3. If you ignore the Preprocessor plist file, you must manually create an initialization file. Otherwise

The first generation of Xcode will fail (unless you do not submit your ". gitignore" file to the Git repository,

Keep the original value in the current state of the file ).

4. the version number will not be updated unless you manually clear and recreate it. This is because it is impossible for Xcode

It caches Info. plist in the Cleanup mode. I also tried a lot around this: To generate a pre-action scheme,

Other running scripts. I didn't think of other methods, but I only had to manually clean up and re-generate them, and lost them at the same time.

The purpose of automatic setting.

The most feasible method

After a lot of Google searches, I found an anonymous comment in an article, and the technical performance mentioned in the comment was better. It

It avoids all the defects of our previous technologies and is easier to set up. All you need to do is to support this technology.

A "run script" script is added after "Copy Bundle Resources" of "build phase.

Script code:

## Set the build number to the current git commit count.# If we're using the Dev scheme, then we'll suffix the build# number with the current branch name, to make collisions# far less likely across feature branches.# Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/#git=`sh /etc/profile; which git`appBuild=`"$git" rev-list --all |wc -l`if [ $CONFIGURATION = "Debug" ]; thenbranchName=`"$git" rev-parse --abbrev-ref HEAD`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild-$branchName" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"else/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"fiecho "Updated ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"

This script uses the PlistBuddy command line tool to edit/foo/DerivedData/bar (also the directory generated by Target)

The version number of Info. plist in the directory. This is why Git will not be corrupted when the version number changes. Every time it is generated

The new version number is not only generated for the first time after the total cleanup, but also has nothing to do with whether you are on the Info. plist page.

 

The above Code was modified on the anonymous reviewer code. It uses Git to submit the version number of the count, but if it detects

In Xcode, we use debugging to generate the configuration. It will add the name and suffix of the current branch after the version number. This avoids parallel

Potential conflicts between different branch versions during development2.

 

November September 14, 2014-update Johan kurl, the coolest name on the internet, corrected my new running script

Some potential problems. The above script has also been updated.

 

Although it is not a big problem, I don't like this specific generation, which will lead to unrecognized crash logs.

This method of adding a suffix after the version number can solve this problem.

Link: http://blog.jaredsinclair.com/post/97193356620/the-best-of-all-possible-xcode-automated-build
I want to develop the iphone on ios and find that many Xcode versions are different in the tutorial. How can I solve this problem?

Although the Xcode version is updated frequently, the basic functions are the same. The focus is on good linguistics.

This is just like a windows system, which is often updated, but the new version does not need to be learned, so this worry is redundant.

Q: I have installed mac OS 106. Which version of Xcode and sdk is better?

We recommend you go to the lions system.
Because the new SDK is released

10.6 only XCODE 3 4 can be used in the system

IOS 5.0 cannot be developed.

But now the mainstream version is 5.0.

So if you want to develop

We recommend that you install the lions system to enjoy the latest features.

If you must develop the snow leopard system

Download.chinamac.com/mac7647.html
This

But not recommended

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.