Skip to content

Commit

Permalink
partially patch google#1977
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 569270337
  • Loading branch information
AlbertWang0116 authored and Szymon Sobecki committed Feb 7, 2024
1 parent 7722d1f commit a9b5152
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions TestLib/XCTestCase/XCUIApplication+GREYEnvironment.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ @implementation XCUIApplication (GREYEnvironment)

- (void)grey_configureApplicationForLaunch {
NSMutableDictionary<NSString *, NSString *> *mutableEnv = [self.launchEnvironment mutableCopy];
NSString *insertionKey = @"DYLD_INSERT_LIBRARIES";
NSString *insertionValue = @"@executable_path/Frameworks/AppFramework.framework/AppFramework";
NSString *alreadyExistingValue = [mutableEnv valueForKey:insertionKey];
NSArray<NSString *> *existingValues = [alreadyExistingValue componentsSeparatedByString:@":"];
if (existingValues && ![existingValues containsObject:insertionValue]) {
insertionValue = [NSString stringWithFormat:@"%@:%@", alreadyExistingValue, insertionValue];
if (![mutableEnv[@"EG_SKIP_INSERT_LIBRARIES"] isEqualToString:@"YES"]) {
NSString *insertionKey = @"DYLD_INSERT_LIBRARIES";
NSString *insertionValue = @"@executable_path/Frameworks/AppFramework.framework/AppFramework";
NSString *alreadyExistingValue = [mutableEnv valueForKey:insertionKey];
NSArray<NSString *> *existingValues = [alreadyExistingValue componentsSeparatedByString:@":"];
if (existingValues && ![existingValues containsObject:insertionValue]) {
insertionValue = [NSString stringWithFormat:@"%@:%@", alreadyExistingValue, insertionValue];
}
[mutableEnv setObject:insertionValue forKey:insertionKey];
}
[mutableEnv setObject:insertionValue forKey:insertionKey];

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

0 comments on commit a9b5152

Please sign in to comment.