1

I have been using React Native for the past 4 of months working both on Android and IOS. According to React Native Docs there will be an updated version of React Native every month. So, I keep updating it every month which is good, but the problem is I am using a couple of npm packages which is getting outdated due to react-native update which in-turn causes errors in my project.

For Android, we can lock the react-native version by specifying the version number in gradle. And for the Javascript part we can lock it in package.json. But for IOS I am not able to find anything like that.

So, is there way to lock the react-native version in IOS xcode?

Val
  • 21,938
  • 10
  • 68
  • 86
Joshua
  • 1,167
  • 1
  • 14
  • 32

1 Answers1

2

Yes, make your package.json file at root path - react-native version to fixed number. for example:

"dependencies": {
    "react-native": "0.50.4",
}

So every time you do npm install, that given version will be installed. without postfix ^ it will never be upgraded.

The react-native version of iOS is just a project / static library import from node_module/react-native/Libraries folder, via react-native link.

Update 1:

Take RCTAnimation.xcodeproj in project for example, you can find it locate at node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj.

enter image description here

Val
  • 21,938
  • 10
  • 68
  • 86
  • If that's how it works, then do you have any idea about what is causing this error? React Native version mismatch: Javascript version: 0.50.3 Native version: 0.51.0 – Joshua Dec 20 '17 at 06:23
  • If that's your case -- version mismatch, you might run into this problem. https://stackoverflow.com/questions/47763824/react-native-version-mismatch – Val Dec 20 '17 at 06:31
  • Updated my answer about the relationship between XCode project and node_modules. – Val Dec 20 '17 at 06:33
  • Awesome! Works great :) – Joshua Dec 20 '17 at 06:47