Why is "react-native link some-native-module" a lottery?
<p>I love React Native, mostly. Have been using it since 0.22. Currently on 0.35.</p>

<p>But why does linking native libraries act like a lottery? I rarely get it to work on the first shot, and the things that break are often completely different things.</p>

<p>Every RN upgrade is a pita. Here is what I usually do:</p>

<ol>
<li>npm i react-native@0.35</li>
<li><code>react-native upgrade</code>   (answer yes on every question to replace files)</li>
<li>insert my stuff in info.plist  (it got replaced..)</li>
<li>reinstall pods</li>
<li>relink all native modules</li>
<li>hold my breath and try <code>react-native run-ios</code></li>
</ol>

<p>Most of the times the above does not work. But it does work when I compile the app from within XCode.</p>

<p>The journey from here to a working <code>run-ios</code> is often long and frustrating. It involves the following:</p>

<ol>
<li>unlink all native modules with <code>react-native unlink xyz</code></li>
<li>manually remove header search paths the unlink didn't remove</li>
<li><code>rm -rf node_modules</code></li>
<li><code>yarn</code></li>
<li>product/clean from within XCode</li>
<li>install pods</li>
<li>link native modules</li>
</ol>

<p>Sometimes the above works. Mostly it doesn't work. Usually some native modules ends up in the build error section when I run from <code>react-native run-ios</code>. Running from XCode works as usual.</p>

<p>The native modules ending up in the error section are not the same every time. I have also had some of the native modules "shipped" with RN error out. (RCTGeolocation, RCTActionSheet, RCTWebSocket) </p>

<p>Next "level" of solution (when I can't get the above) to work is this:</p>

<ol>
<li><code>react-native init nextAppAttempt</code></li>
<li>copy code, assets, .babelrc, etc to the new folder</li>
<li><code>yarn</code></li>
<li>link all modules</li>
<li>install pods</li>
</ol>

<p>I have had some success with the above, but the I have the pita of renaming the app to the real name and re-connecting to my GitHub repo.</p>

<p>Here are the native modules that I'm linking:</p>

<pre><code>react-native link react-native-fs &amp;&amp; \
react-native link react-native-camera &amp;&amp; \
react-native link react-native-code-push \
react-native link react-native-permissions &amp;&amp; \
react-native link react-native-image-resizer &amp;&amp; \
react-native link react-native-mixpanel &amp;&amp; \
react-native link react-native-maps &amp;&amp; \
react-native link react-native-svg &amp;&amp;
</code></pre>

<ul>
<li><p>What's the deal here? </p></li>
<li><p>Does this work for others?</p></li>
<li><p>Are there flaws in my process? (I hope so)</p></li>
</ul>