mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
14 lines
4.8 KiB
Markdown
14 lines
4.8 KiB
Markdown
---
|
|
id: version-0.21-upgrading
|
|
title: upgrading
|
|
original_id: upgrading
|
|
---
|
|
<a id="content"></a><table width="100%"><tbody><tr><td><h1><a class="anchor" name="upgrading"></a>Upgrading <a class="hash-link" href="undefined#upgrading">#</a></h1></td><td style="text-align:right;"><a target="_blank" href="https://github.com/facebook/react-native/blob/master/docs/Upgrading.md">Edit on GitHub</a></td></tr></tbody></table><div><p>Upgrading to new versions of React Native will give you access to more APIs, views, developer tools
|
|
and other goodies. Because React Native projects are essentially made up of an Android project, an
|
|
iOS project and a JavaScript project, all combined under an npm package, upgrading can be rather
|
|
tricky. But we try to make it easy for you. Here's what you need to do to upgrade from an older
|
|
version of React Native:</p><h2><a class="anchor" name="1-upgrade-the-react-native-dependency"></a>1. Upgrade the <code>react-native</code> dependency <a class="hash-link" href="docs/upgrading.html#1-upgrade-the-react-native-dependency">#</a></h2><p>Note the latest version of the <code>react-native</code> npm package from here (or use <code>npm info react-native</code> to check):</p><ul><li><a href="https://www.npmjs.com/package/react-native">https://www.npmjs.com/package/react-native</a></li></ul><p>Now install that version of <code>react-native</code> in your project with <code>npm install --save</code>. For example, to upgrade to the version <code>0.18</code>, in a terminal run:</p><div class="prism language-javascript">$ npm install <span class="token operator">--</span>save react<span class="token operator">-</span>native@<span class="token number">0.18</span></div><h2><a class="anchor" name="2-upgrade-your-project-templates"></a>2. Upgrade your project templates <a class="hash-link" href="docs/upgrading.html#2-upgrade-your-project-templates">#</a></h2><p>The new npm package will likely contain updates to the files that are normally generated when you
|
|
run <code>react-native init</code>, like the iOS and the Android sub-projects. To get these latest changes,
|
|
run this in a terminal:</p><div class="prism language-javascript">$ react<span class="token operator">-</span>native upgrade</div><p>This will check your files against the latest template and perform the following:</p><ul><li>If there is a new file in the template, it is simply created.</li><li>If a file in the template is identical to your file, it is skipped.</li><li>If a file is different in your project than the template, you will be prompted; you have options
|
|
to view a diff between your file and the template file, keep your file or overwrite it with the
|
|
template version. If you are unsure, press <code>h</code> to get a list of possible commands.</li></ul><h1><a class="anchor" name="manual-upgrades"></a>Manual Upgrades <a class="hash-link" href="docs/upgrading.html#manual-upgrades">#</a></h1><p>Xcode project format is pretty complex and sometimes it's tricky to upgrade and merge new changes.</p><h3><a class="anchor" name="from-0-13-to-0-14"></a>From 0.13 to 0.14 <a class="hash-link" href="docs/upgrading.html#from-0-13-to-0-14">#</a></h3><p>The major change in this version happened to the CLI (<a href="https://github.com/facebook/react-native/releases/tag/v0.14.0-rc" target="_blank">see changelog</a>) and static images (<a href="docs/images.html" target="_blank">see docs</a>). To use the new asset system in existing Xcode project, do the following:</p><p>Add new "Run Script" step to your project's build phases:</p><p><img src="https://cloud.githubusercontent.com/assets/192222/11050044/871bf926-86f7-11e5-8908-736106457bcb.png" alt=""></p><p>Set the script to</p><div class="prism language-javascript"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token operator">/</span>node_modules<span class="token operator">/</span>react<span class="token operator">-</span>native<span class="token operator">/</span>packager<span class="token operator">/</span>react<span class="token operator">-</span>native<span class="token operator">-</span>xcode<span class="token punctuation">.</span>sh</div><p><img src="https://cloud.githubusercontent.com/assets/192222/11050052/8f098252-86f7-11e5-994a-364aabbaa7d1.png" alt=""></p><p>Move main.jsbundle to Trash (it will be generated automatically by Xcode using the script above)</p><p><img src="https://cloud.githubusercontent.com/assets/192222/11050104/f3d025e2-86f7-11e5-9101-a4622236338d.png" alt=""></p><p>If you installed Node via nvm, you might experience "react-native: command not found". See <a href="https://github.com/facebook/react-native/issues/3974" target="_blank">issues/3974</a> for workaround and <a href="https://github.com/facebook/react-native/pull/4015" target="_blank">pull/4015</a> for the fix.</p></div><div class="docs-prevnext"><a class="docs-next" href="platform-specific-code.html#content">Next →</a></div> |