From 8e4cace5a3eb774f0819bef756fa9063dd33d0cb Mon Sep 17 00:00:00 2001 From: McCoy Appleseed Date: Sun, 2 Oct 2022 17:05:30 -0400 Subject: [PATCH] fix(macCatalyst): add compilation conditionals for macCatalyst (#629) --- ios/RNCConnectionState.m | 12 ++++++------ ios/RNCNetInfo.m | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ios/RNCConnectionState.m b/ios/RNCConnectionState.m index 663e4925..431e0ccc 100644 --- a/ios/RNCConnectionState.m +++ b/ios/RNCConnectionState.m @@ -6,11 +6,11 @@ */ #import "RNCConnectionState.h" -#if !TARGET_OS_TV +#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST #import #endif -#if TARGET_OS_TV || TARGET_OS_OSX +#if TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST #include #endif @@ -36,16 +36,16 @@ - (instancetype)initWithReachabilityFlags:(SCNetworkReachabilityFlags)flags _type = RNCConnectionTypeUnknown; _cellularGeneration = nil; _expensive = false; - + if ((flags & kSCNetworkReachabilityFlagsReachable) == 0 || (flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0) { _type = RNCConnectionTypeNone; } -#if !TARGET_OS_TV && !TARGET_OS_OSX +#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { _type = RNCConnectionTypeCellular; _expensive = true; - + CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init]; if (netinfo) { if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS] || @@ -73,7 +73,7 @@ - (instancetype)initWithReachabilityFlags:(SCNetworkReachabilityFlags)flags #endif else { _type = RNCConnectionTypeWifi; -#if TARGET_OS_TV || TARGET_OS_OSX +#if TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST struct ifaddrs *interfaces = NULL; struct ifaddrs *temp_addr = NULL; int success = 0; diff --git a/ios/RNCNetInfo.m b/ios/RNCNetInfo.m index 84a0b5e7..e83b8c40 100644 --- a/ios/RNCNetInfo.m +++ b/ios/RNCNetInfo.m @@ -11,7 +11,7 @@ #include #include -#if !TARGET_OS_TV +#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST #import #import #endif @@ -130,7 +130,7 @@ - (NSMutableDictionary *)detailsFromInterface:(nonnull NSString *)requestedInter } else if ([requestedInterface isEqualToString: RNCConnectionTypeWifi] || [requestedInterface isEqualToString: RNCConnectionTypeEthernet]) { details[@"ipAddress"] = [self ipAddress] ?: NSNull.null; details[@"subnet"] = [self subnet] ?: NSNull.null; - #if !TARGET_OS_TV && !TARGET_OS_OSX + #if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST /* Without one of the conditions needed to use CNCopyCurrentNetworkInfo, it will leak memory. Clients should only set the shouldFetchWiFiSSID to true after ensuring requirements are met to get (B)SSID. @@ -146,7 +146,7 @@ Clients should only set the shouldFetchWiFiSSID to true after ensuring requireme - (NSString *)carrier { -#if (TARGET_OS_TV || TARGET_OS_OSX) +#if (TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST) return nil; #else CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init]; @@ -227,7 +227,7 @@ - (NSString *)subnet return subnet; } -#if !TARGET_OS_TV && !TARGET_OS_OSX +#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_MACCATALYST - (NSString *)ssid { NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());