0.44版本ReactNative真机运行的坑

1、手机跟电脑连在同一局域网,xcode选择我的手机。因为低版本需要设置localhost,而现在的版本貌似是不需要的。

打包出现下面的错误


解决方法:

1.到Xcode里选择app下的general栏目将Automatically manage Signing取消check,如果已经取消直接第二步

2.到build settings里设置code signing identity,下属debug和release全部选择IOS Developer。Development team就选择自己的apple id登录的账号就好了。

3.接着打开Xcode → Product → Clean. 然后关闭xcode再重启

4.再到general栏目下勾选Automatically manage signing!这时为你create provisioning profile。

此时可能又会报这样的错:

5.大概的意思就是appid被其他的项目占据了。导致原因是因为我之前真机运行过一个项目,然后被卸载了,重建之后appid依然被之前的项目占据,解决办法就是修改bundle identifier。我的做法直接在后缀加1。

上面的解决完,继续clean -> run。

6很不幸,笔者再次报错:

Can't find 'node' binary to build React Native bundle

 error: Can't find 'node' binary to build React Native bundle
  If you have non-standard nodejs installation, select your project in Xcode,
  find 'Build Phases' - 'Bundle React Native code and images'
  and change NODE_BINARY to absolute path to your node executable
  (you can find it by invoking 'which node' in the terminal)

翻译过来就是你用的非标准的node安装模式!什么nvm安装或者tar文件解压安装的情况,export NODE_BINARY=node是不行的,需要换成node的绝对路径。

 //终端执行
  $ which node    

  //输出node的绝对路径

进入 Build Phases里展开Build React Native Code and Image将得到的路径替换掉node即可。

最后build成功。手机里只要设置app可信任即可!

 

原文地址:https://www.cnblogs.com/douglasvegas/p/6995508.html