Skip to content

Commit a9b5152

Browse files
AlbertWang0116Szymon Sobecki
authored and
Szymon Sobecki
committed
partially patch google#1977
PiperOrigin-RevId: 569270337
1 parent 7722d1f commit a9b5152

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

TestLib/XCTestCase/XCUIApplication+GREYEnvironment.m

+9-7
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ @implementation XCUIApplication (GREYEnvironment)
2020

2121
- (void)grey_configureApplicationForLaunch {
2222
NSMutableDictionary<NSString *, NSString *> *mutableEnv = [self.launchEnvironment mutableCopy];
23-
NSString *insertionKey = @"DYLD_INSERT_LIBRARIES";
24-
NSString *insertionValue = @"@executable_path/Frameworks/AppFramework.framework/AppFramework";
25-
NSString *alreadyExistingValue = [mutableEnv valueForKey:insertionKey];
26-
NSArray<NSString *> *existingValues = [alreadyExistingValue componentsSeparatedByString:@":"];
27-
if (existingValues && ![existingValues containsObject:insertionValue]) {
28-
insertionValue = [NSString stringWithFormat:@"%@:%@", alreadyExistingValue, insertionValue];
23+
if (![mutableEnv[@"EG_SKIP_INSERT_LIBRARIES"] isEqualToString:@"YES"]) {
24+
NSString *insertionKey = @"DYLD_INSERT_LIBRARIES";
25+
NSString *insertionValue = @"@executable_path/Frameworks/AppFramework.framework/AppFramework";
26+
NSString *alreadyExistingValue = [mutableEnv valueForKey:insertionKey];
27+
NSArray<NSString *> *existingValues = [alreadyExistingValue componentsSeparatedByString:@":"];
28+
if (existingValues && ![existingValues containsObject:insertionValue]) {
29+
insertionValue = [NSString stringWithFormat:@"%@:%@", alreadyExistingValue, insertionValue];
30+
}
31+
[mutableEnv setObject:insertionValue forKey:insertionKey];
2932
}
30-
[mutableEnv setObject:insertionValue forKey:insertionKey];
3133

3234
// Pass in this flag so logging is enabled for the application process for both NSLog and OSLog.
3335
mutableEnv[@"OS_ACTIVITY_DT_MODE"] = @"YES";

0 commit comments

Comments
 (0)