react-native ios "Could not connect to development server" and "__fbBatchedBridge is undefined" errors
<h1>react-native ios "Could not connect to development server" and "__fbBatchedBridge is undefined" errors</h1>

<p>I'm freshman in react-native. I tried deploy a "hello world" app according to official documents. But failed.</p>

<p>Here what i try:</p>

<ul>
<li>install all dependencies according to official site</li>
<li>init my local project using command <code>react-native init HelloWorld</code> (At first my project name is <code>try</code>, but it's a reserved keyword, so I changed to <code>HelloWorld</code>)</li>
<li>install all node_modues using <code>npm install</code></li>
<li>try to run my project using command <code>react-native run-ios</code></li>
</ul>

<p>my environments are: </p>

<ul>
<li>osx <code>10.10.5</code></li>
<li>watchman <code>4.5</code></li>
<li>xcode <code>7.2.1</code></li>
<li>react-native-cli <code>1.0.0</code></li>
<li>react-native <code>0.28.0</code></li>
<li>react <code>15.1.0</code></li>
</ul>

<p>After running command <code>react-native run-ios</code>, i got this red background error:</p>

<blockquote>
  <p>Cound not connect to development server.</p>
  
  <p>Ensue the folloing:</p>
  
  <ul>
  <li>Node server is running and available on the same network - run 'npm start' from react-native root</li>
  <li>Node server URL is correctly set in AppDelegate</li>
  </ul>
  
  <p>URL: <a href="http://localhost:8081/index.ios.bundle?platform-ios&amp;dev=true" rel="nofollow">http://localhost:8081/index.ios.bundle?platform-ios&amp;dev=true</a></p>
</blockquote>

<p>I searched google, and found it is a common problem mainly due to osx 9.0 security policy.</p>

<p>I read through the <a href="https://github.com/facebook/react-native/issues/304" rel="nofollow">github issue: cound not connect to development server</a> and check and modify my project:</p>

<ul>
<li><p>make sure <code>NSAppTransportSecurity</code> in <code>Info.plist</code> setting is ok. </p>

<pre><code>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt;
&lt;dict&gt;
    &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
</code></pre></li>
<li><p>tried change <code>jsCodeLocation</code> in <code>AppDelegate.m</code> from <code>localhost</code> to <code>my local network ip</code> (In fact, i can visit the jsCodeLocation[localhost] in my chrome browser, but i changed my ip according to the github issue anyway, just try)</p></li>
</ul>

<p>When i retry the command "react-native run-ios", the connect error disappeared, but come with another error "__fbBatchedBridge is undefined"</p>

<blockquote>
  <p>Unable to execute JS call: __fbBatchedBridge is undefined</p>
  
  <p>RCTFatal + 104
  ...</p>
</blockquote>

<p>I read through the github issue: <code>github-&gt;facebook/react-native/issues/6282</code>, and try commenting out the following lines <code>github-&gt;facebook/react-native/blob/master/packager/react-native-xcode.sh#L15-L18</code></p>

<pre><code>#    if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then        
#      echo "Skipping bundling for Simulator platform"      
#      exit 0;      
#    fi
</code></pre>

<p>But nothing happened. Anybody can help? thank you.</p>