iOS IPA包編譯時間獲取
+ (NSTimeInterval)ipaBuildTime
{
NSString *buildDate = [NSString stringWithFormat:@"%s %s",__DATE__, __TIME__];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
dateFormatter.dateFormat = @"MMM dd yyyy HH:mm:ss";
NSDate *date = [dateFormatter dateFromString:buildDate];
NSTimeInterval timeInterval = [date timeIntervalSince1970];// 單位秒
return timeInterval;
}
另加ANSI C標準中幾個常用標準預(yù)定義宏:
__LINE__
:調(diào)用該宏語句所在的行數(shù)霜定,是個十進制數(shù)
__FILE__
:當前編譯的文件的文件名
__DATE__
:當前編譯的文件的編譯日期
__TIME__
:當前編譯的文件的編譯時間
__STDC__
:當要求程序嚴格遵循ANSI C標準時該標識被賦值為1;
__cplusplus
:當編寫C++程序時該標識符被定義曲稼。
輸出方式為:printf("%s %s", __DATE__, __TIME__);
輸出:Dec 26 2017 17:19:41