Developing with React Native on Windows

I’ve been developing React Native applications a few months now under Windows. As previously I always used a Mac or Linux for development, it was quite frightening to get started. It has its limitations, but works quite well.

Both React and React Native works fine under Windows. Thus most things will work out of the box. On the other hand there are some obvious exceptions:

  • iOS builds (and even linking)
  • custom scripts
  • nvm
  • testing

Building for iOS

The biggest headache for me was how to build for iOS. I really like how quickly I could iterate in Android by using a simulator or an attached device. I’ve lost this possibility by having my Mac sunk under water an year ago. Still, I wanted to get iOS builds somehow.

I quickly realised that I could use a CI service, like Bitrise. This finally saved my life, but I still had to get to a point where my biggest problem will be to actually run the builds.

Unfortunately, it’s simply not possible to develop for iOS without some kind of a Mac. There are threesteps when you’ll still need a Mac:

  1. to run the first successful build and ship it to App Store
  2. to run `react-native link` and have your packages linked for ios too
  3. to test in iOS

It might be possible to get around the first limitation, but it’s much easier to do it from a Mac than by pure trial and error.

I’ve tried to set up a virtual mac, but failed. Thus in the end I signed up for a MacInCloud account. I’ve set up my development environment with them quickly, and since my builds and App Store deployment works through Bitrise I use them sporadically, only when I need to link a new package. It would be awesome to be able to  link for iOS from a Windows machine, and even better if I could run the iOS builds here. I guess the latter will never happen.

Custom scripts

As I really like the Ignite CLI, I immediately run into some Unix-only scripts in the initial boilerplate’s package.json file.  It was easy to fix these though.

e.g the `npm run clean:android` command changed from

"clean:android": "cd android && ./gradlew clean && cd ..",
to
"clean:android": "cd android && .\\gradlew.bat clean && cd ..",
  <p>
    In case of pipes (<code>||</code>), I had to remove them, and come up with some other ideas, but it was not a problem in general.
  </p>
  
  <h2>
    NVM
  </h2>
  
  <p>
    As I use the Ignite CLI, and in their readme you can see that debugging with node 8.0+ might be problematic, I&#8217;ve decided to use a node version manager. This way I can have node LTS for backend projects, and still run 7.10.1 for React Native development.
  </p>
  
  <p>
    NVM on Windows has its limitations, like you can have only a single node version active at a time, but it works well with <a href="https://github.com/coreybutler/nvm-windows">nvm-windows</a>.
  </p>
  
  <h2>
    Testing
  </h2>
  
  <p>
    As much of React Native code runs in pure JS, testing works out of the box for the most part. There is one serious limitation now, but it might be solved in a couple of months.
  </p>
  
  <p>
    I really like the idea of Detox and E2E test runner for React Native. Now, Detox does not run under Windows. I&#8217;ve tried to get it running for a few hours, but there seem to be several limitations right now, and would need to spend more time to make it work.
  </p>
</div>