* [iOS] update Rax logic

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/2e01ca20
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/2e01ca20
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/2e01ca20

Branch: refs/heads/master
Commit: 2e01ca20ffa2369d670c02bb5ffd857cb231926d
Parents: e3a909e
Author: acton393 <[email protected]>
Authored: Wed Jan 10 16:00:43 2018 +0800
Committer: acton393 <[email protected]>
Committed: Wed Jan 10 16:00:43 2018 +0800

----------------------------------------------------------------------
 WeexSDK.podspec                                  |  2 +-
 ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2e01ca20/WeexSDK.podspec
----------------------------------------------------------------------
diff --git a/WeexSDK.podspec b/WeexSDK.podspec
index 73c8a46..abadcdc 100644
--- a/WeexSDK.podspec
+++ b/WeexSDK.podspec
@@ -28,7 +28,7 @@ Pod::Spec.new do |s|
   s.ios.deployment_target = '7.0'
   s.source =  { :path => '.' }
   s.source_files = 'ios/sdk/WeexSDK/Sources/**/*.{h,m,mm,c}'
-  s.resources = 'pre-build/native-bundle-main.js', 
'ios/sdk/WeexSDK/Resources/[email protected]'
+  s.resources = 'pre-build/native-bundle-main.js', 
'pre-build/weex-rax-api.js', 'ios/sdk/WeexSDK/Resources/[email protected]'
 
   s.user_target_xcconfig  = { 'FRAMEWORK_SEARCH_PATHS' => 
"'$(PODS_ROOT)/WeexSDK'" }
   s.requires_arc = true

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2e01ca20/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m 
b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
index e83fa04..3fb3a42 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
@@ -482,6 +482,15 @@ _Pragma("clang diagnostic pop") \
                 }
                 JSObjectSetProperty(instanceContextRef, globalObject, 
propertyName, [instanceContextEnvironment valueForProperty:key].JSValueRef, 0, 
NULL);
             }
+            if ([bundleType isEqualToString:@"Rax"]) {
+                NSString *filePath = [[NSBundle bundleForClass:[weakSelf 
class]] pathForResource:@"weex-rax-api" ofType:@"js"];
+                NSString *script = [NSString stringWithContentsOfFile:filePath 
encoding:NSUTF8StringEncoding error:nil];
+                if (script) {
+                    [sdkInstance.instanceJavaScriptContext 
evaluateScript:script];
+                } else {
+                    WXLogError(@"weex-rax-api can not found");
+                }
+            }
             
             [sdkInstance.instanceJavaScriptContext 
evaluateScript:jsBundleString];
         }];
@@ -517,7 +526,8 @@ _Pragma("clang diagnostic pop") \
     }
     if ([jsBundleString hasPrefix:@"// { \"framework\": \"Vue\" }"] || 
[jsBundleString hasPrefix:@"// { \"framework\": \"vue\" }"]) {
         bundleType = @"Vue";
-    } else if ([jsBundleString hasPrefix:@"// { \"framework\": \"Rax\" }"] || 
[jsBundleString hasPrefix:@"// { \"framework\": \"rax\" }"]) {
+    } else if ([jsBundleString hasPrefix:@"// { \"framework\": \"Rax\" }"] || 
[jsBundleString hasPrefix:@"// { \"framework\": \"rax\" }"] ||\
+               [jsBundleString hasPrefix:@"// {\"framework\" : \"Rax\"}"] || 
[jsBundleString hasPrefix:@"// {\"framework\" : \"rax\"}"]) {
         bundleType = @"Rax";
     }else {
         // use the top 100 characters match the bundleType

Reply via email to