I am developing an app for both Android and iOS using React Native.
One of the libraries I'm using is a bit problematic because the app only compiles correctly:
- ...on Android when using
"react-native": "0.42.0"
. - ...on iOS when using
"react-native": "0.37.0"
.
(Neither the library itself , nor the specific versions of react-native
are important for this discussion. What's important is that I seemingly need two separate versions "at the same time" - a different one for each platform.)
I'm looking for a way to have a single codebase that can compile using the relevant tools for either platform w/o any modification1. The solutions I thought of are (to somehow):
- Specify different package versions for each mobile OS.
- Have completely different
package.json
files for each platform.
However, I have no idea how either of the above can be achieved or if they're even possible. I tried adding .ios
and .android
as explained in the React-Native docs on platform-specific code, but npm doesn't recognize these files.
So my questions are:
- Are my ideas feasible, and if so - how?
- Is there any other ways to get the desired result?
1 In C-like code, this would've been easy with pre-processor flags.