2016-10-10 76 views

回答

0

首先,使用“react-native bundle”命令进行捆绑。现在,你会得到一个main.js束。

然后,把main.jsbundle放到你的xcode项目中,像添加资源一样添加。

最后,请确保您使用RCTBridge启动RCTRootView,实现委托“sourceUrlForBridge”。

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 
 
{ 
 
    
 
// NSString *jsBundlePath = @"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"; 
 
// NSURL *jsBundleURL = [NSURL URLWithString:jsBundlePath]; 
 
    
 
    
 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"main" ofType:@"jsbundle"]; 
 
    NSURL *jsBundleURL = [NSURL URLWithString:path]; 
 
    
 
    return jsBundleURL; 
 
}

相关问题