美文网首页
React Native--"No bundle UR

React Native--"No bundle UR

作者: 青苹果园 | 来源:发表于2018-05-24 11:59 被阅读260次
    No bundle URL present

    第一次安装运行RN项目时,执行react-native run-ios 报如上图“No bundle URL present”错误。

    谷歌了下各种解决方案:

    // 项目在模拟器运行状态执行如下代码:
    npm install
    react-native run-ios
    
    // 修改AppDelegate.m代码:
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
    改为
    jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&;dev=true"];
    
    修改代理sadowsocks VPN, 调整全局代理
    

    ……


    以上都试过了都不能解决我的问题,最后发现是需要配置host,才能正常访问本地资源:

    1. 终端输入 Swiftsudo vi /etc/hosts ,输入密码后,添加 127.0.0.1 localhost即可。

    2. 安装一个 SwitchHosts! 软件,管理本地host(推荐),添加 127.0.0.1 localhost 并开启。

    SwitchHosts!

    相关文章

      网友评论

          本文标题:React Native--"No bundle UR

          本文链接:https://www.haomeiwen.com/subject/fuajjftx.html