Last active
August 29, 2015 14:18
-
-
Save jpotts18/163304e6819cab450b81 to your computer and use it in GitHub Desktop.
iOS User Agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script automatically sets the version and short version string of | |
# an Xcode project from the Git repository containing the project. | |
# | |
# To use this script in Xcode 4, add the contents to a "Run Script" build | |
# phase for your application target. | |
set -o errexit | |
set -o nounset | |
GIT_COMMIT=$(git rev-parse --verify HEAD | cut -c 1-7) | |
GIT_COMMIT_COUNT=$(git rev-list master | wc -l) | |
# this will fail if you don't have a tag | |
GIT_TAG=$(git describe --abbrev=0) | |
defaults write $PRODUCT_SETTINGS_PATH GitCommit $GIT_COMMIT | |
defaults write $PRODUCT_SETTINGS_PATH CommitCount $GIT_COMMIT_COUNT | |
defaults write $PRODUCT_SETTINGS_PATH GitTag $GIT_TAG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// JPUserAgentHelper.m | |
// | |
// Created by Jeff Potter on 4/1/15. | |
// | |
#import "JPUserAgentHelper.h" | |
@implementation JPUserAgentHelper | |
+ (NSString *)appName | |
{ | |
return @"Sweet App"; | |
} | |
+ (NSString *) appVersion | |
{ | |
return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; | |
} | |
+ (NSString *) deviceName | |
{ | |
return [[UIDevice currentDevice] name]; | |
} | |
+ (NSString *) operatingSystemVersion | |
{ | |
return [[UIDevice currentDevice] systemVersion]; | |
} | |
+ (NSString *) commitHash | |
{ | |
return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"GitCommit"]; | |
} | |
+ (NSString *) agentString | |
{ | |
return [NSString stringWithFormat:@"%@/%@/%@ (%@;%@)", [JPUserAgentHelper appName], [JPUserAgentHelper appVersion], [JPUserAgentHelper commitHash], [JPUserAgentHelper deviceName], [JPUserAgentHelper operatingSystemVersion]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment