React Native项目从0.28升级到0.29 (iOS)

React Native项目从0.28升级到0.29 (iOS)


备忘纪要:


1.升级react-native到0.29.0版本 

方法一:

到项目跟目录下,cmd运行命令: react-native-git-upgrade 0.29.0,运行完毕后,应该没有ERROR类型的消息,会有一些提示信息:需要修改等等,表示react-native升级成功。

参考文章:http://blog.csdn.net/jiangbo_phd/article/details/54693335

方法二:

用 react-nativve-git-upgrade 0.29.0升级失败的情况下,手动升级,方法如下:


Alternative

Use this only in case the above didn't work.

1. Upgrade the react-native dependency

Note the latest version of the react-native npm package from here (or use npm info react-native to check).

Now install that version of react-native in your project with npm install --save:

$ npm install --save [email protected]
# where X.Y is the semantic version you are upgrading to
npm WARN peerDependencies The peer dependency react@~R included from react-native...

If you saw a warning about the peerDependency, also upgrade react by running:

$ npm install --save react@R
# where R is the new version of react from the peerDependency warning you saw

2. Upgrade your project templates(慎用react-native upgrade,如果不熟悉iOS开发,最好是不要执行这一步,只执行第一步既可以:npm install --save [email protected]

The new npm package may contain updates to the files that are normally generated when you run react-native init, like the iOS and the Android sub-projects.

You may consult rn-diff to see if there were changes in the project template files. In case there weren't any, simply rebuild the project and continue developing. In case of minor changes, you may update your project manually and rebuild.

If there were major changes, run this in a terminal to get these:

$ react-native upgrade

This will check your files against the latest template and perform the following:

  • If there is a new file in the template, it is simply created.
  • If a file in the template is identical to your file, it is skipped.
  • If a file is different in your project than the template, you will be prompted; you have options to keep your file or overwrite it with the template version.


2.  没有使用react-native upgrade命令,这个命令会修改相关模板文件,导致原项目中很多地方需要修改,本次升级并没有使用

慎用react-native upgrade,如果不熟悉iOS开发,最好是不要执行这一步,只执行第一步既可以:npm install --save [email protected]


3. 链接项目RCTWebSocket.m文件编译时,会提示没有处理返回值,按照下面截图的方式处理;

如果有其他项目编译出错,则按照提示进行修改




4. 注意:命令执行完毕后,会自动把之前的某些第三方的插件删除(node_modules目录下),具体原因未知,从原来的备份的文件中将丢失的模块拷贝到升级后的项目中既可。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章