react native: No bundle url present

//  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];


将上面的换成下面的:

如果到要真机上测试,127.0.0.1需要换成自己的网络ip。(当然还要有证书)

#ifdef DEBUG

    jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.bundle?platform=ios&dev=true"];

#else

  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main"withExtension:@"jsbundle"];

#endif


此外:上面应该就好了。如果不好,有人说是网络权限问题:

My problem has been solved by adding NSAllowsLocalNetworking to Info.plist

NSAppTransportSecurity

NSAllowsArbitraryLoads

NSAllowsArbitraryLoadsInWebContent

NSAllowsLocalNetworking

你可能感兴趣的:(react native: No bundle url present)