Skip to content

Instantly share code, notes, and snippets.

@mahipalsingh7
Created September 4, 2019 12:52
Show Gist options
  • Save mahipalsingh7/9819a854b41239d29e9489e6492e32e2 to your computer and use it in GitHub Desktop.
Save mahipalsingh7/9819a854b41239d29e9489e6492e32e2 to your computer and use it in GitHub Desktop.
How to Upgrade the Reactnative to ~0.60
How to Upgrade the Reactnative to ~0.60
STEp 1: take complete Project Backup run below cmds
// delete watchman
$ watchman watch-del-all
// delete temporary files
$ rm -rf $TMPDIR/react-*
$ rm -rf $TMPDIR/npm-*
$ rm -rf $TMPDIR/haste-*
$ rm -rf $TMPDIR/metro-*
$ rm -rf $TMPDIR/haste-map-react-native-packager-*
// delete and reinstall node modules
$ rm -rf node_modules
$ rm -rf package-lock.json
// delete and re-install CocoaPods, if any
$ rm -rf ios/Pods
$ cd ios
$ pod cache clean --all
// clean native build folders (as seen above)
$ ./android/gradlew clean -p ./android/
$ rm -rf ios/build
// clean iOS simulator files, replace "appName" with your own
$ rm -rf ~/Library/Developer/Xcode/DerivedData/appName-*
STep 2: Now Update the package.json File
"dependencies": {
....
"react": "16.8.6",
"react-native": "0.60.5",
}
"devDependencies": {
"@babel/core": "7.4.3",
"@babel/runtime": "7.4.3",
"babel-jest": "24.7.1",
"jest": "24.7.1",
"metro-react-native-babel-preset": "0.53.1",
"react-native-clean-project": "^3.0.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
},
STep 3 : Run npm install again.
STEp 4: run react-native upgrade and please keep your eyes on Questions,
STep 5: run react-native run-ios and react-native run-android
STep 6: npm install -D metro-react-native-babel-preset
STep 7: Autolinking already Available in React-native, but we still require dependency wise
a: Please delete the pod folder, Workspace, and podlock file
b: react-native unlink package-name
c: npm uninstall --save package-name
d: b & c will be apply on all installed third party dependency
e: Reinstall all those again and use react-native link package-name
STep 8: Under App gradle : Update the andorid object
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.ifasapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2097163
versionName "3.0"
// ndk {
// abiFilters "armeabi-v7a", "x86", "arm64-v8a"//"armeabi-v7a", "x86" //'armeabi-v7a','arm64-v8a','x86','x86_64'//
// }
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"//"armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
// manifestPlaceholders = [excludeSystemAlertWindowPermission: "false"]
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
STep 9: Android gradle:
classpath 'com.android.tools.build:gradle:3.3.1'
//FIREBASE
classpath 'com.google.gms:google-services:4.2.0'//4.0.2'
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
STep 10: Now for iOS Some dependency like firebase , fabric, crashlacties need pod dep. so add only those dependency in Pod file and remove all the reset of the dependencies.
STep 11: Open the Project and check you should have all the .a lib in Linked Framworks
STep 12: add JavaScript.framework
STep 13: Those project which support firebase please check these versions
npm install — save [email protected]
classpath 'com.google.gms:google-services:4.2.0' // build.gradel file
implementation "com.google.android.gms:play-services-base:17.0.0"
implementation "com.google.firebase:firebase-core:17.0.1"
implementation "com.google.firebase:firebase-messaging:19.0.0"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar' <-- Add this line if you wish to use badge on Android
STep 14: Android support network security ATS with HTTPS
a. create a "xml" name folder & add network_security_config.xml file: under app/src/mai/res
b. add below code in network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">myserver.com</domain>
</domain-config>
</network-security-config>
c. At AndroidManifest
add xmlns:tools="http://schemas.android.com/tools" in menifest
add following code under application tag
<application
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:appComponentFactory"
android:appComponentFactory="anystrings be placeholder"
>
STep 15: at Gradle.properties
add
android.useAndroidX=true
android.enableJetifier=true
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip //gradle-wrapper
STep 16: all done use "react-native run-android/ios" to compile , best of luck for other errors!
More help: https://medium.com/@marcelkalveram/upgrading-react-native-to-version-0-59-and-beyond-a-step-by-step-guide-d4c2926dd482
https://medium.com/@katharinep/firebase-notification-integration-in-react-native-0-60-3a8d6c8d56ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment