From 7f0b04afa2a058b9df6c00866bfe0a38f9640559 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Tue, 17 Apr 2018 11:08:30 -0400 Subject: Fix version number reporting for minor versions. (#1124) * Fix version number reporting for minor versions. * run clang-format * Updated the comment in systemVersion. --- Firebase/Core/third_party/FIRAppEnvironmentUtil.m | 38 ++++++++++------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'Firebase/Core') diff --git a/Firebase/Core/third_party/FIRAppEnvironmentUtil.m b/Firebase/Core/third_party/FIRAppEnvironmentUtil.m index 8e76201..be4e971 100644 --- a/Firebase/Core/third_party/FIRAppEnvironmentUtil.m +++ b/Firebase/Core/third_party/FIRAppEnvironmentUtil.m @@ -97,7 +97,7 @@ static BOOL isAppEncrypted() { BOOL is64bit = (executableHeader->magic == MH_MAGIC_64); uintptr_t cursor = (uintptr_t)executableHeader + - (is64bit ? sizeof(struct mach_header_64) : sizeof(struct mach_header)); + (is64bit ? sizeof(struct mach_header_64) : sizeof(struct mach_header)); const struct segment_command *segmentCommand = NULL; uint32_t i = 0; @@ -162,8 +162,7 @@ static BOOL isAppEncrypted() { // Info.plist if developers opted out of this check. id enableSandboxCheck = [[NSBundle mainBundle] objectForInfoDictionaryKey:kFIRAppStoreReceiptURLCheckEnabledKey]; - if (enableSandboxCheck && - [enableSandboxCheck isKindOfClass:[NSNumber class]] && + if (enableSandboxCheck && [enableSandboxCheck isKindOfClass:[NSNumber class]] && ![enableSandboxCheck boolValue]) { return NO; } @@ -174,20 +173,20 @@ static BOOL isAppEncrypted() { } + (BOOL)hasEmbeddedMobileProvision { - #if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV return [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"].length > 0; - #elif TARGET_OS_OSX +#elif TARGET_OS_OSX return NO; - #endif +#endif } + (BOOL)isSimulator { - #if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV NSString *platform = [FIRAppEnvironmentUtil deviceModel]; return [platform isEqual:@"x86_64"] || [platform isEqual:@"i386"]; - #elif TARGET_OS_OSX +#elif TARGET_OS_OSX return NO; - #endif +#endif } + (NSString *)deviceModel { @@ -204,13 +203,10 @@ static BOOL isAppEncrypted() { } + (NSString *)systemVersion { - // Assemble the systemVersion, excluding any insignificant digits. + // Assemble the systemVersion, excluding the patch version if it's 0. NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion; - NSMutableString *versionString = [[NSMutableString alloc] initWithFormat:@"%ld", (long)osVersion.majorVersion]; - if (osVersion.minorVersion != 0) { - [versionString appendFormat:@".%ld", (long)osVersion.minorVersion]; - } - + NSMutableString *versionString = [[NSMutableString alloc] + initWithFormat:@"%ld.%ld", (long)osVersion.majorVersion, (long)osVersion.minorVersion]; if (osVersion.patchVersion != 0) { [versionString appendFormat:@".%ld", (long)osVersion.patchVersion]; } @@ -219,25 +215,25 @@ static BOOL isAppEncrypted() { } + (BOOL)isAppExtension { - #if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV // Documented by Apple BOOL appExtension = [[[NSBundle mainBundle] bundlePath] hasSuffix:@".appex"]; return appExtension; - #elif TARGET_OS_OSX +#elif TARGET_OS_OSX return NO; - #endif +#endif } #pragma mark - Helper methods + (BOOL)hasSCInfoFolder { - #if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV NSString *bundlePath = [NSBundle mainBundle].bundlePath; NSString *scInfoPath = [bundlePath stringByAppendingPathComponent:@"SC_Info"]; return [[NSFileManager defaultManager] fileExistsAtPath:scInfoPath]; - #elif TARGET_OS_OSX +#elif TARGET_OS_OSX return NO; - #endif +#endif } @end -- cgit v1.2.3