React-Native No Bundle URL present

贼气,网上各种方法没有。
后来一看就是localhost解析不出来

- (NSString *)guessPackagerHost
{
  static NSString *ipGuess;
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    NSString *ipPath = [[NSBundle mainBundle] pathForResource:@"ip" ofType:@"txt"];
    ipGuess = [[NSString stringWithContentsOfFile:ipPath encoding:NSUTF8StringEncoding error:nil]
               stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
  });

  NSString *host = ipGuess ?: @"localhost";
  if ([self isPackagerRunning:host]) {
    return host;
  }

看看源代码有加载ip.txt
直接写了一个ip.txt文件,写上自己的网络ip
解决!!!

你可能感兴趣的:(React-Native No Bundle URL present)