Showing App's Build Date
You might consider using the built-in __DATE__
and __TIME__
macros which will return a string representation of the date and time the app was built. Perhaps they will be of more help to you:
NSString *dateStr = [NSString stringWithUTF8String:__DATE__];
NSString *timeStr = [NSString stringWithUTF8String:__TIME__];
To get build date with format 'yyMMddHHmm' you could try this:
+ (NSString *)GetBuildDate {
NSString *buildDate;
// Get build date and time, format to 'yyMMddHHmm'
NSString *dateStr = [NSString stringWithFormat:@"%@ %@", [NSString stringWithUTF8String:__DATE__], [NSString stringWithUTF8String:__TIME__]];
// Convert to date
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"LLL d yyyy HH:mm:ss"];
NSDate *date = [dateFormat dateFromString:dateStr];
// Set output format and convert to string
[dateFormat setDateFormat:@"yyMMddHHmm"];
buildDate = [dateFormat stringFromDate:date];
[dateFormat release];
return buildDate;
}
Try running the script as a build phase step, rather than a scheme pre-action step, so it's run all the time, regardless of the type of build you are producing.