From 1e6331980d8645e4cb453d876429507b72e0c62b Mon Sep 17 00:00:00 2001 From: Xiao Chen Date: Fri, 20 Nov 2020 17:59:23 -0800 Subject: [PATCH] Update DYLD_FALLBACK_LIBRARY_PATH to the new path (#416) We found an app launch crash where it complains cannot load image @rpath/libXCTestSwiftSupport.dylib. This dylib is in "platform/Developer/usr/lib" which has an updated path over the years of Xcode evolvement. Updating the `DYLD_FALLBACK_LIBRARY_PATH` to use the new path so the simulator can pick up the dylib. Co-authored-by: Ravi Kumar Mandala --- bp/src/SimulatorHelper.m | 4 ++-- bp/tests/SimulatorHelperTests.m | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bp/src/SimulatorHelper.m b/bp/src/SimulatorHelper.m index bdab6afd..4c5dd297 100644 --- a/bp/src/SimulatorHelper.m +++ b/bp/src/SimulatorHelper.m @@ -73,7 +73,7 @@ + (NSDictionary *)appLaunchEnvironmentWithBundleID:(NSString *)hostBundleID } NSMutableDictionary *environment = [@{ @"DYLD_FALLBACK_FRAMEWORK_PATH" : [NSString stringWithFormat:@"%@/Library/Frameworks:%@/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks", config.xcodePath, config.xcodePath], - @"DYLD_FALLBACK_LIBRARY_PATH" : [NSString stringWithFormat:@"%@/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib", config.xcodePath], + @"DYLD_FALLBACK_LIBRARY_PATH" : [NSString stringWithFormat:@"%@/Platforms/iPhoneSimulator.platform/Developer/usr/lib", config.xcodePath], @"DYLD_INSERT_LIBRARIES" : libXCTestBundleInjectValue, @"DYLD_LIBRARY_PATH" : [NSString stringWithFormat:@"%@/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks", config.xcodePath], @"DYLD_ROOT_PATH" : [NSString stringWithFormat:@"%@/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot", config.xcodePath], @@ -155,7 +155,7 @@ + (NSString *)testEnvironmentWithConfiguration:(BPConfiguration *)config { + (NSString *)bundleIdForPath:(NSString *)path { NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:[path stringByAppendingPathComponent:@"Info.plist"]]; - + NSString *platform = [dic objectForKey:@"DTPlatformName"]; if (platform && ![platform isEqualToString:@"iphonesimulator"]) { [BPUtils printInfo:ERROR withString:@"Wrong platform in %@. Expected 'iphonesimulator', found '%@'", path, platform]; diff --git a/bp/tests/SimulatorHelperTests.m b/bp/tests/SimulatorHelperTests.m index 663ce007..ee66f7cd 100644 --- a/bp/tests/SimulatorHelperTests.m +++ b/bp/tests/SimulatorHelperTests.m @@ -20,7 +20,7 @@ @implementation SimulatorHelperTests - (void)setUp { [super setUp]; - + [BPUtils quietMode:[BPUtils isBuildScript]]; } @@ -40,6 +40,7 @@ - (void)testAppLaunchEnvironment { config.outputDirectory = @"/Users/test/output"; NSDictionary *appLaunchEnvironment = [SimulatorHelper appLaunchEnvironmentWithBundleID:hostBundleId device:nil config:config]; XCTAssert([appLaunchEnvironment[@"DYLD_FALLBACK_FRAMEWORK_PATH"] containsString:@"Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks"]); + XCTAssert([appLaunchEnvironment[@"DYLD_FALLBACK_LIBRARY_PATH"] containsString:@"Platforms/iPhoneSimulator.platform/Developer/usr/lib"]); XCTAssert([appLaunchEnvironment[@"DYLD_INSERT_LIBRARIES"] containsString:@"libXCTestBundleInject.dylib"]); XCTAssert([appLaunchEnvironment[@"DYLD_LIBRARY_PATH"] containsString:@"/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks"]); XCTAssert([appLaunchEnvironment[@"XCTestConfigurationFilePath"] containsString:@"T/BPSampleAppTests-"]);