Skip to content

Commit

Permalink
Update DYLD_FALLBACK_LIBRARY_PATH to the new path (#416)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
chenxiao0228 and ravimandala authored Nov 21, 2020
1 parent db09487 commit 1e63319
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bp/src/SimulatorHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ + (NSDictionary *)appLaunchEnvironmentWithBundleID:(NSString *)hostBundleID
}
NSMutableDictionary<NSString *, NSString *> *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],
Expand Down Expand Up @@ -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];
Expand Down
3 changes: 2 additions & 1 deletion bp/tests/SimulatorHelperTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ @implementation SimulatorHelperTests

- (void)setUp {
[super setUp];

[BPUtils quietMode:[BPUtils isBuildScript]];

}
Expand All @@ -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-"]);
Expand Down

0 comments on commit 1e63319

Please sign in to comment.