diff --git a/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m b/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m index cf768fcb..5358d0c9 100644 --- a/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m +++ b/doric-iOS/Pod/Classes/Engine/DoricJSEngine.m @@ -127,9 +127,13 @@ - (void)initJSExecutor { - (void)initDoricEnvironment { @try { - [self loadBuiltinJS:DORIC_BUNDLE_SANDBOX]; - NSString *path = [DoricBundle() pathForResource:DORIC_BUNDLE_LIB ofType:@"js"]; + NSString *path; + if (@available(iOS 10.0, *)) { + path = [DoricBundle() pathForResource:DORIC_BUNDLE_LIB ofType:@"js"]; + } else { + path = [DoricBundle() pathForResource:[NSString stringWithFormat:@"%@.es5", DORIC_BUNDLE_LIB] ofType:@"js"]; + } NSString *jsContent = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; [self.jsExecutor loadJSScript:[self packageModuleScript:DORIC_MODULE_LIB content:jsContent] source:[@"Module://" stringByAppendingString:DORIC_MODULE_LIB]]; @@ -139,7 +143,12 @@ - (void)initDoricEnvironment { } - (void)loadBuiltinJS:(NSString *)fileName { - NSString *path = [DoricBundle() pathForResource:DORIC_BUNDLE_SANDBOX ofType:@"js"]; + NSString *path; + if (@available(iOS 10.0, *)) { + path = [DoricBundle() pathForResource:DORIC_BUNDLE_SANDBOX ofType:@"js"]; + } else { + path = [DoricBundle() pathForResource:[NSString stringWithFormat:@"%@.es5", DORIC_BUNDLE_SANDBOX] ofType:@"js"]; + } NSString *jsContent = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; [self.jsExecutor loadJSScript:jsContent source:[@"Assets://" stringByAppendingString:fileName]]; }