Ad

React Native - Differences Between Android And IOS

- 1 answer

Is the code for building an app for ios and android the same or are they different? I know there are two separate files one with .ios and one with .android but that's about where my knowledge ends. This is for react native. Thanks!

Ad

Answer

The base setup for building with Android and iOS are the same, but once you start getting into the development of your app, there are a few differences. From what I've experienced, we can probably bet on using about 80% of our code cross platform. I've heard of others using up to 90%, and I've normally heard the number being around 85%.

To use the code cross platform, you would just copy the code from your .ios.js or .android.js file, and copy it into the other. As long as there are not platform specific components, it should work.

Also:

  1. There are a few modules that were build specifically for iOS, and there are a few that were specifically built for Android, and some of them work cross platform. For example, ActivityIndicatorIOS (https://facebook.github.io/react-native/docs/activityindicatorios.html#content) is an iOS styled element, but if you look in the component itself, you will see both ActivityIndicatorIOS.android.js and ActivityIndicatorIOS.ios.js, so it should at least work cross platform, but UI will probably not be what you would be looking for in Android.

  2. If you install any plugins that need to access any native functionality, for example using a custom font, you will need to do a bit of work separately (on each platform) to get them working for each platform and it will not work cross platform.

  3. Bridging will be entirely different for each platform, though this may not be something you would even have to worry about unless you needed to do something that React Native does not support out of the box.

  4. To build in IOS, you will need a Mac and Xcode. To build in Android, you will need the android SDK and some type of emulator (I use Genymotion). But keep in mind that as of now, you can't develop iOS on a Windows machine unless you use something like ExponentJS, but if you have a Mac, you can develop cross platform.

Ad
source: stackoverflow.com
Ad