From a91305641963cc0c15fc1a1e634f836c6242ca43 Mon Sep 17 00:00:00 2001 From: Yingliu Chen Date: Wed, 3 Oct 2018 06:39:37 -0700 Subject: [PATCH] Do NOT use direct launch when video recording is enabled in Xcode 10 Summary: See title. In Xcode 10 video recording doesn't work on direct launched simulator, but works on simulators launched Simulator.app, so we don't use direct launch in this case. Reviewed By: lawrencelomax Differential Revision: D10147771 fbshipit-source-id: aea7b735e440148b7a32debcb5a6766830953398 --- FBControlCore/Utility/FBXcodeConfiguration.h | 5 +++++ FBControlCore/Utility/FBXcodeConfiguration.m | 5 +++++ .../FBXCTestKit/Runners/FBXCTestSimulatorFetcher.m | 14 +++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/FBControlCore/Utility/FBXcodeConfiguration.h b/FBControlCore/Utility/FBXcodeConfiguration.h index 0caff120..ba08eb7b 100644 --- a/FBControlCore/Utility/FBXcodeConfiguration.h +++ b/FBControlCore/Utility/FBXcodeConfiguration.h @@ -64,6 +64,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, assign, readonly, class) BOOL isXcode9OrGreater; +/** + YES if Xcode 10 or greater, NO Otherwise. + */ +@property (nonatomic, assign, readonly, class) BOOL isXcode10OrGreater; + /** YES if passing a custom SimDeviceSet to the Simulator App is Supported. */ diff --git a/FBControlCore/Utility/FBXcodeConfiguration.m b/FBControlCore/Utility/FBXcodeConfiguration.m index b99d93b0..e723cd48 100644 --- a/FBControlCore/Utility/FBXcodeConfiguration.m +++ b/FBControlCore/Utility/FBXcodeConfiguration.m @@ -97,6 +97,11 @@ return [FBXcodeConfiguration.xcodeVersionNumber compare:[NSDecimalNumber decimalNumberWithString:@"9.0"]] != NSOrderedAscending; } ++ (BOOL)isXcode10OrGreater +{ + return [FBXcodeConfiguration.xcodeVersionNumber compare:[NSDecimalNumber decimalNumberWithString:@"10.0"]] != NSOrderedAscending; +} + + (BOOL)supportsCustomDeviceSets { // Prior to Xcode 7, 'iOS Simulator.app' calls `+[SimDeviceSet defaultSet]` directly diff --git a/fbxctest/FBXCTestKit/Runners/FBXCTestSimulatorFetcher.m b/fbxctest/FBXCTestKit/Runners/FBXCTestSimulatorFetcher.m index 6378fb0d..fd7d2e64 100644 --- a/fbxctest/FBXCTestKit/Runners/FBXCTestSimulatorFetcher.m +++ b/fbxctest/FBXCTestKit/Runners/FBXCTestSimulatorFetcher.m @@ -82,9 +82,21 @@ - (FBFuture *)fetchSimulatorForApplicationTest:(FBXCTestDestinationiPhoneSimulator *)destination { + FBSimulatorBootOptions options = FBSimulatorBootOptionsEnableDirectLaunch | FBSimulatorBootOptionsVerifyUsable; + + if (FBXcodeConfiguration.isXcode10OrGreater) { + NSMutableDictionary *environment = [NSProcessInfo.processInfo.environment mutableCopy]; + NSString *videoRecordingPath = environment[@"FBXCTEST_VIDEO_RECORDING_PATH"]; + if (videoRecordingPath != nil) { + // rdar://44907260 + // In Xcode 10, we need to launch Simulator.app to setup simulator properly for enabling video recording. + options &= ~FBSimulatorBootOptionsEnableDirectLaunch; + } + } + FBSimulatorBootConfiguration *bootConfiguration = [[FBSimulatorBootConfiguration defaultConfiguration] - withOptions:FBSimulatorBootOptionsEnableDirectLaunch | FBSimulatorBootOptionsVerifyUsable]; + withOptions:options]; return [[self fetchSimulatorForLogicTest:destination]