Skip to content

Commit

Permalink
feat: update react native version to 0.70
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori committed Jun 18, 2024
1 parent 4845e87 commit 9126124
Show file tree
Hide file tree
Showing 10 changed files with 3,224 additions and 2,575 deletions.
129 changes: 89 additions & 40 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,59 +1,108 @@
buildscript {
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['ExperimentReactNativeClient_kotlinVersion']
repositories {
google()
mavenCentral()
}
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["ExperimentReactNativeClient_kotlinVersion"]

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: "com.android.library"
apply plugin: "kotlin-android"


def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ExperimentReactNativeClient_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ExperimentReactNativeClient_" + name]).toInteger()
}

def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
if (major == 7 && minor >= 3) {
return true
}

return major >= 8
}

android {
compileSdkVersion safeExtGet('ExperimentReactNativeClient_compileSdkVersion', 31)
buildToolsVersion safeExtGet('ExperimentReactNativeClient_buildToolsVersion', '31.0.0')
defaultConfig {
minSdkVersion safeExtGet('ExperimentReactNativeClient_minSdkVersion', 21)
targetSdkVersion safeExtGet('ExperimentReactNativeClient_targetSdkVersion', 31)
versionCode 1
versionName "1.0"
if (supportsNamespace()) {
namespace "com.amplitude.experiment.reactnative"

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
}

buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable 'GradleCompatible'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
buildTypes {
release {
minifyEnabled false
}
}

lintOptions {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
google()
mavenCentral()
mavenCentral()
google()
}

def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "ExperimentReactNativeClient"
codegenJavaPackageName = "com.amplitude.experiment.reactnative"
}
}
7 changes: 4 additions & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ExperimentReactNativeClient_kotlinVersion=1.6.21
ExperimentReactNativeClient_compileSdkVersion=31
ExperimentReactNativeClient_buildToolsVersion=31.0.0
ExperimentReactNativeClient_kotlinVersion=1.7.0
ExperimentReactNativeClient_minSdkVersion=21
ExperimentReactNativeClient_targetSdkVersion=31
ExperimentReactNativeClient_compileSdkVersion=31
ExperimentReactNativeClient_ndkversion=21.4.7075529
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
2 changes: 2 additions & 0 deletions android/src/main/AndroidManifestNew.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PODS:
- boost-for-react-native (1.63.0)
- CocoaAsyncSocket (7.6.5)
- DoubleConversion (1.1.6)
- experiment-react-native-client (1.0.0):
- experiment-react-native-client (1.5.0):
- React-Core
- FBLazyVector (0.63.4)
- FBReactNativeSpec (0.63.4):
Expand Down Expand Up @@ -447,7 +447,7 @@ SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: cde416483dac037923206447da6e1454df403714
experiment-react-native-client: c2af8630b6209c5d4dcebdcd71ba7ad38abdcc38
experiment-react-native-client: 2a27a01aa9e78ce23686e6ea5fbc1d86dd7bc0b4
FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
Flipper: 1bd2db48dcc31e4b167b9a33ec1df01c2ded4893
Expand Down Expand Up @@ -487,4 +487,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: be8ac95a530dede03d7b3bef7b71d1e8fb613dfc

COCOAPODS: 1.11.3
COCOAPODS: 1.15.2
9 changes: 6 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"start": "react-native start"
},
"dependencies": {
"react": "16.13.1",
"react-native": "0.63.4",
"@types/react": "^16.9.19",
"react": "^17.0.2",
"react-native": "0.67.4",
"@types/react": "^17.0.80",
"@types/react-native": "0.67.8",
"@react-native-async-storage/async-storage": "^1.17.6",
"@amplitude/analytics-react-native": "0.0.1-dev.1"
Expand All @@ -22,5 +22,8 @@
"@babel/runtime": "^7.12.5",
"babel-plugin-module-resolver": "^4.0.0",
"metro-react-native-babel-preset": "^0.64.0"
},
"resolutions": {
"@types/react": "17.0.80"
}
}
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Variants,
} from '@amplitude/experiment-react-native-client';
import * as React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
const [variant, setVariant] = React.useState<Variant | undefined>();
Expand Down
Loading

0 comments on commit 9126124

Please sign in to comment.