Thursday, July 12, 2012

Automatically add Git hash to Info.plist in Xcode

Here is a script to add a git hash to your app Info.plist when building. The script can also add the git status (clean or not). It does not require preprocessing of the Info.plist, extra targets, or temporary files that must be ignored by git. The script works by modifying the Info.plist in the finished build, so it does not disturb the project working directory and your clean git state.

Open up the Info.plist file and add two properties with keys GitShaHash, and GitState. These values will be overwritten during the build process. I have seen similar scripts that work by storing the hash in CFBundleVersion instead. However, OS X uses CFBundleVersion to compare versions of the same app, and the Mac App Store also requires updates to have a sequential CFBundleVersion. Since the git hash is not sequential, it's better to just leave CFBundleVersion alone and relegate it to an under the hood value.

Select the project target, and add a run script build phase:

Copy and paste the script in. This is a perl scrip so the shell must be set to /usr/bin/perl . Note that the line “my $INFO …” is set for Mac app bundles, you can switch the commented lines around for iOS apps.

use strict;
use warnings;

die "$0: Must be run from Xcode" unless $ENV{"BUILT_PRODUCTS_DIR"};

my $FH;
my $output;

# SHA hash :

open $FH, "xcrun git rev-parse HEAD|" or die;
$output = <$FH>;
close($FH);

chomp( $output );
my $gitShaHash = $output;

# clean state :

$output = `xcrun git status`;

my $gitState;
if ( index( $output, "nothing to commit (working directory clean)" ) != -1 ) {
    $gitState = "clean";
} else {
    $gitState = "dirty";
}

print "gitShaHash : $gitShaHash\n";
print "gitState : $gitState";

# Update Info.plist in build product. Use defaults command

#my $INFO = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Info"; #iOS
my $INFO = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Contents/Info"; #OSX

my @defaults = ( 'defaults', 'write', $INFO, 'GitShaHash', "$gitShaHash" );
system( @defaults );

@defaults = ( 'defaults', 'write', $INFO, 'GitState', "$gitState" );
system( @defaults );

All done, now the values will be generated every time you build and the values can be accessed easily from the Info.plist using code:

NSURL *url = [[[NSBundle mainBundle] bundleURL] URLByAppendingPathComponent:@"Contents/Info.plist"];
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:url];

NSString *hash = [dictionary objectForKey:@"GitShaHash"];
NSString *state = [dictionary objectForKey:@"GitState"];

It’s a good idea to place the values within the about panel or a similar location. The hash can make it easier to track issues with beta testers. And the git state makes it easier to prevent dirty builds from being distributed.

21 comments:

Ross Franklin said...

Edited the script to use xcrun for git commands; enables the script to work on Xcode installations without the command line tools installed.

Yoshiki said...

How did you add this information to the credits window?

Unknown said...

Excellent post...
outsource invoice processing services

Satta King said...

Satta King game is drawing and lottery-based generally match-up, anyway right now it's sorted in betting.
Satta King
Satta King Gali
Satta King Gali
Satta King Desawar
Satta King Faridabad
Satta King Ghaziabad
Satta King Ghaziabad Delhi Darbar
Satta King Peshawar
Satta King Gali
Satta King Game
Satta King Faridabad
Satta King Delhi Darbar
Satta King Desawar
Satta King Ghaziabad
Satta king live result
Satta king online result
Satta king online
Satta king result today
Satta king gali result
Satta king desawar result
Satta king faridabad result
Satta king gaziyabad result
Satta king delhi darbar result
Satta matka king
Satta king up
Satta king desawar
Satta king gali
Satta king 2020 chart
Satta king 2019 chart
Satta king 2021 chart
Satta baba king
Satta king chart
Gali live result
desawar live result
faridabad live result
ghaziabad live result
delhi darbar live result

Darren Demers said...

Open up the Info.plist file and add two properties with keys GitShaHash, and GitState. These values will be overwritten during the build process. I have seen similar scripts that work by storing the hash in CFBundleVersion instead. light pink little girl dress , childrens yellow dress , red and black little girl dresses , emerald green toddler dress However, OS X uses CFBundleVersion to compare versions of the same app, and the Mac App Store also requires updates to have a sequential CFBundleVersion. Since the git hash is not sequential, it's better to just leave CFBundleVersion alone and relegate it to an under the hood value.

AOL Help 24/7 said...

Amazing post, I do not read anything like that before! AOL Mail Supports Team here is a well-researched guide to Recover AOL Password online. And you might end up losing your account password in an effort to protect the account. or this problem, Dial AOL Email Supports Toll-Free Number and get instant help.

Riya Rai said...

There were a few explanations behind being with the Bhubaneswar Escorts Call Girl. Despite the fact that the most ideal approach to just looking for Bhubaneswar Escorts on Google and search for some great escort agency in the city. We are a dependable Bhubaneswar Escorts, Odisha. We are known for our benevolent Bhubaneswar Escorts and independent escorts available 24×7 to meet in a call.

Kavita Sharma said...


Man of his word Only Calls Now 9081684265 Best High-Class call girls Service Escorts Home Hotel in Lucknow 24 Hours Available High Profile Call Girls Short 2000. Night 6000...
Lucknow Escorts
Escorts in Lucknow

Call girls in mahipalpur said...

Delhi Call Girls Agency, we are one among the various escort organization providing food young ladies for sexual administrations in Delhi and NCR. Our administrations are expanded all over Delhi and edges. We keep up unmistakable class of young ladies at all the majority of noticeable districts of the Delhi to guarantee our customers immediate and wanted administrations. Our Call Girls in Delhi are best class of young ladies giving extreme joy and furthermore moving message to not to surrender except if you achieve your point. Our Escort Service in Delhi attempt to change viewpoint towards life however yes they show the procedures to appreciate life and grin against the odd of life. Likewise become familiar with the procedures to make meeting more acceptable and interesting with escort young ladies.

Call girls in mahipalpur said...

We are related with qualified, taught proficient and elegant escort young ladies so you can invest a decent energy with these Call Girls in Mahipalpur. Our youngsters can offer their organizations at five-star lodgings, four-star motels or three-star hotels too yet in case you moreover need organization at your home they can even come there as well, they can come and visit you seven evenings each week holding up the early hours of the sunrise generally advantageous and real administrations. So Guys view our best choice of world Escort Service in Mahipalpur benefits, and connect with our telephone chief and request the best young lady chose by you from our image display. We are even accessible in a wide zone of Delhi-NCR for our administrations.

Call girls in mahipalpur said...

This is the best escort services in Connaught Place may be gainful for you on the off chance that you are looking for a mindful female partner. We give prominent call girls in Connaught place for your happiness and ravishment. In the event that you're remaining in any lavish lodging close to Connaught Place, selecting an escort young lady may upgrade your delight. We have an incredible assortment which includes a scope of alternatives so you can pick what sort of young lady makes your day. These Escort Service in Connaught place have assumed control over the holy messengers and appear to be an impression of prostitutes. There is a ton organized your delight, for example, extravagance bars and clubs where you can meet with complex females of the town. Indeed, you would happy to realize that a large number of the esteemed women of metropolitan zones of Delhi are our regarded bunch individuals. You can get one of them by calling @ 9654120218.

Call girls in mahipalpur said...

Call Girls in Paharganj: - We are the unparalleled rumored accompanies administration in Paharganj from most recent couple of years. We have the Call girls in Paharganj from any remaining areas. Our Call young ladies in Paharganj are sought after for the voyagers, outsiders and many businessmen's. You can get easygoing gatherings with hot young ladies whenever they are likewise the craving to meet you. In the event that you are feeling desolate and searching for a delightful partner who can give all your necessities, at that 000int you are continuing immediately. We can orchestrate a calm sentimental date for you with our Paharganj Escorts the help is open all day, every day for you. We have a huge assortment of young ladies to settle on your longing and decisions complete. Our escorts organization currently turns into a top decision for everybody and this on account of our quality help to customers. Escorts Service in Paharganj is consistently accessible at your support of offer you the best Escorts joy in Paharganj.

Ragani Tiwari said...

Hello connections, are you looking Rolling Hot Rolling Mill Manufacturer in India for getting best deal at reasonable prices. So then consider Akshi Engineers Pvt. Ltd. Company for all those requirements related to Hot Rolling Mill. For more information visit our website or dial our contact number, our sales team is 24*7 here to list your business needs.

Call girls in mahipalpur said...

Are you guys exploring modern, impressive Delhi Escort Service in Delhi? We questioned this because we are suitable for conducting premium class and pretty Delhi Call Girls for your satisfaction. If you've got been lonely for an extended time, so some time has begun. We are here to supply the foremost essential services in Delhi to you. Yes, we are talking escort services in Delhi, which has imperialism of the cutest girls within the city. We penetrate the intensity of your heart to watch your wants, and this is often what keeps us better to the remainder of others. it's difficult to be alone during this exotic city of the state .
Call Girls in Delhi could be a far better choice for a few space for spending class time and enjoying romantic dates. the foremost satisfying part is that these expert love-makers are accessible at rock bottom rates. If you're looking for entertainment here, so what might be better than selecting an escort girl in Delhi?
https://delhiescortsnearme.blogspot.com/2021/04/cheap-rate-escort-service-in-delhi-any.html
https://sites.google.com/view/escortdelhi/home

Call girls in mahipalpur said...

Welcome to the destination of life describing it's never complete without a partner. every one should have some needfulness of a partner in their life. a number of the lads are lucky they need more friends and that they are proud of their needfulness. But there are many that have the aim to still found their final destination. Welcome to the planet of the incredible lifetime of Call Girls in Mahipalpur. You’ll have your true companion for any event you've got within the world. Our Mahipalpur Escorts provides an entrancing choice for a high-quality time during a city of sovereign people.
Escort Service in Mahipalpur were making real-time opportunities to supply a magical companionship for the critical phase of the meeting. Now, brooding about the premium escorts service, enjoy the creamy Mahipalpur Escorts Service with our female escorts. you'll feel the important joy of companionship which may offer you perfect happiness and privacy. We are covering each and each aspect to gratify your needs.
https://mahipalpurescortaerocity.blogspot.com/2021/04/Charming-escort-services-in-mahipalpur.html
https://sites.google.com/view/escortconnaughtplace/home

Call girls in mahipalpur said...

After browsing a true tedious work schedule on day to day , men would have the natural wants for a few kind of relaxation and happiness. it's very obvious that the women having the glamorous appearance and desirability would be ranking within the higher position compared to the standard individuals within the list. Such is that the case with the women performing at our agency and therefore the time spend under their guidance is actually fascinating enough to quench the lusty matters of men. Independent call girls in Connaught place is understood to be the foremost intriguing experts being the perfect choice for in call also as outcall mode of services.
It would be very easy and cozy to possess these enchanting hotdog babes in your arms as they're highly cooperative in nature and behavior. There would be few loss incurred by the purchasers to possess these ladies involved in Escort Service in Connaught place as their intimate partners who have the capabilities of providing the utmost level of erotic entertainment.
https://escortconnaughtplace.blogspot.com/2021/04/Call-girls-in-Connaught-Place.html
https://sites.google.com/view/call-girls-in-connaught-place/home

Call girls in mahipalpur said...

The girls are entertaining and sparking they skills to charge your body. They like to entertain new peoples who are affected by a stressful life. all of them wish to provide you with the pleasure of a high level. we offer you together with your choice and desirable Escorts in Paharganj for the acute sex. Our agency has many Call girls in Paharganj who are from a special community. a number of the women are a university student, busty ramp models and therefore the hot housewives who are trying to find hardcore sex.
The girl will satisfy your sexual needs and take you the peak of utmost pleasure. all of them girls love, to be frank, or close with strangers, they not want to waste time with an uneventful life and she or he loves the thrills of the sexual comrade. Our Escorts Service in Paharganj are highly qualified and well mannered, you'll also get her for the occasions and therefore the parties.
Click here > > paharganj escort

https://escortspaharganj.blogspot.com/2021/04/Escorts-Service-in-Paharganj%20.html
https://sites.google.com/view/call-girl-in-paharganj/home

Call girl in Aerocity said...

If you're want service for the fun a night with our daring and pleasant girls then choose the services of Paharganj, Call Girls service in Paharganj and Noida so you’ll contact any time, Airport Hotel Delhi, Call Girls & Call Girls in Paharganj, Delhi Call Girls, VIP Call Girls, Bengali girls, Top VIP Call Girls, Housewife, Independent Punjabi Call Girls, Here you will get everything that you simply simply would adore in your Erotic partners then you're on right path. Our Paharganj escorts services can provide you with the services and best pleasure that a private want. Paharganj is that the place of latest Delhi Airport wherever you'll get everything at their best whether or not it's related to the pleasance or to be relaxed from your daily routine. we'll give you some gutsy and unprecedented evenings with our choice women in Paharganj which is during a situation to be a sweet and waiting night for you.
Click now: - Escorts Service in Paharganj

Call girl in Aerocity said...

Friends If you're within the category of not having any girls option and getting to search for Escorts, and Call Girls in Mahipalpur or Housewife to fill color your life then you're at the proper place because we will fill this blankness or lack of your life in seconds and may serve you the simplest instantly if you'd wish to get the service at a time day or within the night you'll contact us and obtain your dream girl.
We have a good collection of all sort of escorts like Models, Independent Escort, College Girls, Housewives, Celebrities, Airhostess, Foreigners, and lots of more.
We are related to eligible, educated professional and high-class escort girls in order that you'll spend an honest time with these Escort Service in Mahipalpur. Our girls offers their services at five-star hotels, four-star hotels or three-star hotels also but if you furthermore may want service at your home they will even come there too.
Click now:- Escort Service in Mahipalpur

Call girl in Aerocity said...

Escort services are being quite common nowadays. Everyone knew that when one is looking forward to approaching Connaught Place escorts, they're looking forward to having some fun and pleasure. But it's not necessary that in your area also the Independent Connaught Place escorts are available.
But now there's no need for you to urge worried about Escorts Services in Connaught Place is out there everywhere for you. you only got to approach the service provider and let him realize your requirements. There could be numerous questions that are rising in your mind considering the escort service in Connaught Place if you've got not availed it earlier. you would possibly be thinking, is it necessary to avail the same? But if you've got such questions in your mind and here, a number of the items are mentioned which will assist you to know whether you're able to avail of the Call Girls in Connaught place or not. At the very first, it's a requirement for a person to urge physically and mentally satisfied.
click here:- Call Girls in Connaught place

Call girl in Aerocity said...

Escort Service in Aerocity for full fun and delight time during a few days. it's been seen that during a few days clients coming from other cities and countries are beguiled by observing these sites today I’m attempting to totally confound me. I even have shared some significant data about the Aerocity Escorts Service. I will be able to attempt to arrange you on how individuals aren't mistaken for the Escort Service in Delhi site who got to appreciate genuine they need to pick the right guide agency in light of the very fact that the foremost stressing thing has emerged here.
Click here > > Call girls in Aerocity