iOS:use es5 lib when under iOS 10

This commit is contained in:
pengfei.zhou 2020-01-15 18:15:10 +08:00 committed by osborn
parent 87bd8ca0f9
commit 8ed3c42d3a

View File

@ -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]];
}