Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[WEEX-489][iOS] Fix resource not loaded when using dynamic framework …
Browse files Browse the repository at this point in the history
…solution in some cases.
  • Loading branch information
caixiaomin committed Jul 2, 2018
1 parent 9e8f8f6 commit df0eb7d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ - (void)createInstance:(NSString *)instanceIdString
sdkInstance.bundleType = bundleType;
if ([bundleType.lowercaseString isEqualToString:@"rax"]) {
raxAPIScriptPath = [[NSBundle bundleForClass:[weakSelf class]] pathForResource:@"weex-rax-api" ofType:@"js"];
if (raxAPIScriptPath == nil) {
raxAPIScriptPath = [[NSBundle mainBundle] pathForResource:@"weex-rax-api" ofType:@"js"];
}
raxAPIScript = [NSString stringWithContentsOfFile:raxAPIScriptPath encoding:NSUTF8StringEncoding error:nil];
if (!raxAPIScript) {
WXLogError(@"weex-rax-api can not found");
Expand Down Expand Up @@ -565,6 +568,9 @@ - (void)createInstance:(NSString *)instanceIdString

if (WX_SYS_VERSION_LESS_THAN(@"10.2")) {
NSString *filePath = [[NSBundle bundleForClass:[weakSelf class]] pathForResource:@"weex-polyfill" ofType:@"js"];
if (filePath == nil) {
filePath = [[NSBundle mainBundle] pathForResource:@"weex-polyfill" ofType:@"js"];
}
NSString *script = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
if (script) {
[sdkInstance.instanceJavaScriptContext executeJavascript:script withSourceURL:[NSURL URLWithString:filePath]];
Expand Down
6 changes: 6 additions & 0 deletions ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ + (void)initSDKEnvironment
}
}
NSString *filePath = [[NSBundle bundleForClass:self] pathForResource:fileName ofType:@"js"];
if (filePath == nil) {
filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"js"];
}
NSString *script = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[WXSDKEngine initSDKEnvironment:script];

Expand Down Expand Up @@ -309,6 +312,9 @@ + (void)restart
}
}
NSString *filePath = [[NSBundle bundleForClass:self] pathForResource:fileName ofType:@"js"];
if (filePath == nil) {
filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"js"];
}
NSString *script = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[self restartWithScript:script];
}
Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/WeexSDK/Sources/View/WXErrorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ - (id) initWithFrame:(CGRect)frame
UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.bounds];
NSBundle *bundle = [NSBundle bundleForClass:self.class];
NSString *file = [bundle pathForResource:@"wx_load_error@3x" ofType:@"png"];
if (file == nil) {
file = [[NSBundle mainBundle] pathForResource:@"wx_load_error@3x" ofType:@"png"];
}
imageView.image = [UIImage imageWithContentsOfFile:file];
[self addSubview:imageView];

Expand Down

0 comments on commit df0eb7d

Please sign in to comment.