fix loading of dynamic linked JavaScriptCore on iOS simulator

Reviewed By: michalgr

Differential Revision: D3703392

fbshipit-source-id: 670185de1eefd1c542de2df96e40aede3b2c12cc
This commit is contained in:
Ben Nham
2016-08-11 18:32:38 -07:00
committed by Facebook Github Bot
parent 0e204e1141
commit ce2f119222

View File

@@ -21,16 +21,18 @@ static void *RCTCustomLibraryHandler(void)
static dispatch_once_t token;
static void *handler;
dispatch_once(&token, ^{
const char *path = [[[NSBundle mainBundle] pathForResource:@"JavaScriptCore"
ofType:nil
inDirectory:@"Frameworks/JavaScriptCore.framework"] UTF8String];
if (path) {
handler = dlopen(path, RTLD_LAZY);
if (!handler) {
RCTLogWarn(@"Can't load custom JSC library: %s", dlerror());
handler = dlopen("@executable_path/Frameworks/JavaScriptCore.framework/JavaScriptCore", RTLD_LAZY);
if (!handler) {
const char *err = dlerror();
// Ignore the dlopen failure if custom JSC wasn't included in our app
// bundle. Unfortunately dlopen only provides string based errors.
if (err != nullptr && strstr(err, "image not found") == nullptr) {
RCTLogWarn(@"Can't load custom JSC library: %s", err);
}
}
});
return handler;
}