diff options
Diffstat (limited to 'Firebase/Core/FIRAppEnvironmentUtil.m')
-rw-r--r-- | Firebase/Core/FIRAppEnvironmentUtil.m | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/Firebase/Core/FIRAppEnvironmentUtil.m b/Firebase/Core/FIRAppEnvironmentUtil.m index b88b432..b3c6913 100644 --- a/Firebase/Core/FIRAppEnvironmentUtil.m +++ b/Firebase/Core/FIRAppEnvironmentUtil.m @@ -23,7 +23,7 @@ /// The encryption info struct and constants are missing from the iPhoneSimulator SDK, but not from /// the iPhoneOS or Mac OS X SDKs. Since one doesn't ever ship a Simulator binary, we'll just /// provide the definitions here. -#if TARGET_IPHONE_SIMULATOR && !defined(LC_ENCRYPTION_INFO) +#if TARGET_OS_SIMULATOR && !defined(LC_ENCRYPTION_INFO) #define LC_ENCRYPTION_INFO 0x21 struct encryption_info_command { uint32_t cmd; @@ -152,12 +152,20 @@ static BOOL isAppEncrypted() { } + (BOOL)hasEmbeddedMobileProvision { + #if TARGET_OS_IOS return [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"].length > 0; + #elif TARGET_OS_OSX + return NO; + #endif } + (BOOL)isSimulator { + #if TARGET_OS_IOS NSString *platform = [FIRAppEnvironmentUtil deviceModel]; return [platform isEqual:@"x86_64"] || [platform isEqual:@"i386"]; + #elif TARGET_OS_OSX + return NO; + #endif } + (NSString *)deviceModel { @@ -174,15 +182,24 @@ static BOOL isAppEncrypted() { } + (NSString *)systemVersion { + #if TARGET_OS_IOS return [UIDevice currentDevice].systemVersion; + #elif TARGET_OS_OSX + return [NSProcessInfo processInfo].operatingSystemVersionString; + #endif } + (BOOL)isAppExtension { + #if TARGET_OS_IOS // Documented by <a href="https://goo.gl/RRB2Up">Apple</a> BOOL appExtension = [[[NSBundle mainBundle] bundlePath] hasSuffix:@".appex"]; return appExtension; + #elif TARGET_OS_OSX + return NO; + #endif } +#if TARGET_OS_IOS + (UIApplication *)sharedApplication { if ([FIRAppEnvironmentUtil isAppExtension]) { return nil; @@ -195,13 +212,22 @@ static BOOL isAppEncrypted() { } return sharedApplication; } +#elif TARGET_OS_OSX ++ (NSApplication *)sharedApplication { + return [NSApplication sharedApplication]; +} +#endif #pragma mark - Helper methods + (BOOL)hasSCInfoFolder { + #if TARGET_OS_IOS NSString *bundlePath = [NSBundle mainBundle].bundlePath; NSString *scInfoPath = [bundlePath stringByAppendingPathComponent:@"SC_Info"]; return [[NSFileManager defaultManager] fileExistsAtPath:scInfoPath]; + #elif TARGET_OS_OSX + return NO; + #endif } @end |