Skip to content

Commit

Permalink
[NFC] Remove unneccessary visionOS #if logic (#197)
Browse files Browse the repository at this point in the history
* [NFC] Remove unneccessary visionOS #if logic

* Remove 'defined(TARGET_OS_VISION)'

* sed -i '' 's/TARGET_OS_IOS && !TARGET_OS_VISION/TARGET_OS_IOS/'

* Extra
  • Loading branch information
ncooke3 authored Jun 28, 2024
1 parent 4268e6f commit 83fa5a9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
6 changes: 2 additions & 4 deletions GoogleUtilities/AppDelegateSwizzler/GULAppDelegateSwizzler.m
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,7 @@ - (BOOL)application:(GULApplication *)application

#endif // TARGET_OS_IOS || TARGET_OS_TV

// TODO(Xcode 15): When Xcode 15 is the minimum supported Xcode version,
// it will be unnecessary to check if `TARGET_OS_VISION` is defined.
#if TARGET_OS_IOS && (!defined(TARGET_OS_VISION) || !TARGET_OS_VISION)
#if TARGET_OS_IOS

- (BOOL)application:(GULApplication *)application
openURL:(NSURL *)url
Expand Down Expand Up @@ -733,7 +731,7 @@ - (BOOL)application:(GULApplication *)application
return returnedValue;
}

#endif // TARGET_OS_IOS && (!defined(TARGET_OS_VISION) || !TARGET_OS_VISION)
#endif // TARGET_OS_IOS

#pragma mark - [Donor Methods] Network overridden handler methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import <Foundation/Foundation.h>

#if TARGET_OS_IOS || TARGET_OS_TV || (defined(TARGET_OS_VISION) && TARGET_OS_VISION)
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION

#import <UIKit/UIKit.h>

Expand Down
9 changes: 4 additions & 5 deletions GoogleUtilities/Environment/GULAppEnvironmentUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ + (NSString *)deviceSimulatorModel {
model = @"watchOS Simulator";
#elif TARGET_OS_TV
model = @"tvOS Simulator";
#elif defined(TARGET_OS_VISION) && TARGET_OS_VISION
#elif TARGET_OS_VISION
model = @"visionOS Simulator";
#elif TARGET_OS_IOS
switch ([[UIDevice currentDevice] userInterfaceIdiom]) {
Expand Down Expand Up @@ -195,8 +195,7 @@ + (NSString *)deviceSimulatorModel {
+ (NSString *)systemVersion {
#if TARGET_OS_IOS
return [UIDevice currentDevice].systemVersion;
#elif TARGET_OS_OSX || TARGET_OS_TV || TARGET_OS_WATCH || \
(defined(TARGET_OS_VISION) && TARGET_OS_VISION)
#elif TARGET_OS_OSX || TARGET_OS_TV || TARGET_OS_WATCH || TARGET_OS_VISION
// Assemble the systemVersion, excluding the patch version if it's 0.
NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion;
NSMutableString *versionString = [[NSMutableString alloc]
Expand Down Expand Up @@ -225,7 +224,7 @@ + (NSString *)applePlatform {
// `true`, which means the condition list is order-sensitive.
#if TARGET_OS_MACCATALYST
applePlatform = @"maccatalyst";
#elif TARGET_OS_IOS && (!defined(TARGET_OS_VISION) || !TARGET_OS_VISION)
#elif TARGET_OS_IOS
if (@available(iOS 14.0, *)) {
// Early iOS 14 betas do not include isiOSAppOnMac (#6969)
applePlatform = ([[NSProcessInfo processInfo] respondsToSelector:@selector(isiOSAppOnMac)] &&
Expand All @@ -241,7 +240,7 @@ + (NSString *)applePlatform {
applePlatform = @"macos";
#elif TARGET_OS_WATCH
applePlatform = @"watchos";
#elif defined(TARGET_OS_VISION) && TARGET_OS_VISION
#elif TARGET_OS_VISION
applePlatform = @"visionos";
#endif // TARGET_OS_MACCATALYST

Expand Down
4 changes: 2 additions & 2 deletions GoogleUtilities/Reachability/GULReachabilityChecker.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ - (GULReachabilityStatus)statusForFlags:(SCNetworkReachabilityFlags)flags {
// Reachable flag is set. Check further flags.
if (!(flags & kSCNetworkReachabilityFlagsConnectionRequired)) {
// Connection required flag is not set, so we have connectivity.
#if TARGET_OS_IOS || TARGET_OS_TV || (defined(TARGET_OS_VISION) && TARGET_OS_VISION)
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION
status = (flags & kSCNetworkReachabilityFlagsIsWWAN) ? kGULReachabilityViaCellular
: kGULReachabilityViaWifi;
#elif TARGET_OS_OSX
Expand All @@ -191,7 +191,7 @@ - (GULReachabilityStatus)statusForFlags:(SCNetworkReachabilityFlags)flags {
!(flags & kSCNetworkReachabilityFlagsInterventionRequired)) {
// If the connection on demand or connection on traffic flag is set, and user intervention
// is not required, we have connectivity.
#if TARGET_OS_IOS || TARGET_OS_TV || (defined(TARGET_OS_VISION) && TARGET_OS_VISION)
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION
status = (flags & kSCNetworkReachabilityFlagsIsWWAN) ? kGULReachabilityViaCellular
: kGULReachabilityViaWifi;
#elif TARGET_OS_OSX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ - (void)testApplePlatform {
// and `TARGET_OS_IOS` are `true` when building a macCatalyst app.
#if TARGET_OS_MACCATALYST
NSString *expectedPlatform = @"maccatalyst";
#elif TARGET_OS_IOS && (!defined(TARGET_OS_VISION) || !TARGET_OS_VISION)
#elif TARGET_OS_IOS
NSString *expectedPlatform = @"ios";
#elif TARGET_OS_TV
NSString *expectedPlatform = @"tvos";
Expand All @@ -106,9 +106,9 @@ - (void)testApplePlatform {
NSString *expectedPlatform = @"watchos";
#endif // TARGET_OS_MACCATALYST

#if defined(TARGET_OS_VISION) && TARGET_OS_VISION
#if TARGET_OS_VISION
NSString *expectedPlatform = @"visionos";
#endif // defined(TARGET_OS_VISION) && TARGET_OS_VISION
#endif // TARGET_OS_VISION

XCTAssertEqualObjects([GULAppEnvironmentUtil applePlatform], expectedPlatform);
}
Expand All @@ -118,7 +118,7 @@ - (void)testAppleDevicePlatform {
// `true`.
#if TARGET_OS_MACCATALYST
NSString *expectedPlatform = @"maccatalyst";
#elif TARGET_OS_IOS && (!defined(TARGET_OS_VISION) || !TARGET_OS_VISION)
#elif TARGET_OS_IOS
NSString *expectedPlatform = @"ios";

if ([[UIDevice currentDevice].model.lowercaseString containsString:@"ipad"] ||
Expand All @@ -139,9 +139,9 @@ - (void)testAppleDevicePlatform {
NSString *expectedPlatform = @"watchos";
#endif // TARGET_OS_WATCH

#if defined(TARGET_OS_VISION) && TARGET_OS_VISION
#if TARGET_OS_VISION
NSString *expectedPlatform = @"visionos";
#endif // defined(TARGET_OS_VISION) && TARGET_OS_VISION
#endif // TARGET_OS_VISION

XCTAssertEqualObjects([GULAppEnvironmentUtil appleDevicePlatform], expectedPlatform);
}
Expand Down

0 comments on commit 83fa5a9

Please sign in to comment.