Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for react-native 0.71 #1199

Merged
merged 1 commit into from
Jan 4, 2023
Merged

feat: add support for react-native 0.71 #1199

merged 1 commit into from
Jan 4, 2023

Conversation

tido64
Copy link
Member

@tido64 tido64 commented Nov 11, 2022

Description

When upgrading to this version, please update your build.gradle to using getReactNativeDependencies(). This will reduce breakages when moving to 0.71 and beyond:

diff --git a/example/android/build.gradle b/example/android/build.gradle
index 984a681..29ef8ce 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,7 +1,6 @@
 buildscript {
     def androidTestAppDir = "../node_modules/react-native-test-app/android"
     apply(from: "${androidTestAppDir}/dependencies.gradle")
-    apply(from: "${androidTestAppDir}/test-app-util.gradle")

     repositories {
         mavenCentral()
@@ -9,12 +8,8 @@ buildscript {
     }

     dependencies {
-        classpath("com.android.tools.build:gradle:${androidPluginVersion}")
-
-        def isNightly = getPackageVersionNumber("react-native", rootDir) == 0
-        if (isNightly || isNewArchitectureEnabled(project)) {
-            classpath("com.facebook.react:react-native-gradle-plugin")
-            classpath("de.undercouch:gradle-download-task:5.3.0")
+        getReactNativeDependencies().each { dependency ->
+            classpath(dependency)
         }
     }
 }

Resolves #1198.

Platforms affected

  • Android
  • iOS
  • macOS
  • Windows

Test plan

Use the script to test 0.64, 0.68, 0.71, nightly:

scripts/test-matrix.sh 0.71

When getting to Fabric builds, you will have to make changes to App.js since react-native-safe-area-context is not yet compatible with latest new arch changes:

diff --git a/example/App.js b/example/App.js
index c9cd14d..f63758d 100644
--- a/example/App.js
+++ b/example/App.js
@@ -2,6 +2,7 @@
 import React, { useCallback, useMemo, useState } from "react";
 import {
   NativeModules,
+  SafeAreaView,
   ScrollView,
   StatusBar,
   StyleSheet,
@@ -10,7 +11,6 @@ import {
   useColorScheme,
   View,
 } from "react-native";
-import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
 // @ts-expect-error
 import { version as coreVersion } from "react-native/Libraries/Core/ReactNativeVersion";
 import { Colors, Header } from "react-native/Libraries/NewAppScreen";
@@ -169,7 +169,6 @@ const App = ({ concurrentRoot }) => {
   );

   return (
-    <SafeAreaProvider>
       <SafeAreaView style={styles.body}>
         <StatusBar barStyle={isDarkMode ? "light-content" : "dark-content"} />
         <ScrollView
@@ -192,7 +191,6 @@ const App = ({ concurrentRoot }) => {
           </View>
         </ScrollView>
       </SafeAreaView>
-    </SafeAreaProvider>
   );
 };

Screenshots

Configuration Android iOS
JSC n/a Simulator Screen Shot - iPhone 14 - 2022-12-02 at 09 30 50
Hermes Screenshot_1669969582 Simulator Screen Shot - iPhone 14 - 2022-12-02 at 09 33 29
Fabric n/a Simulator Screen Shot - iPhone 14 - 2022-12-02 at 10 20 17
Fabric + Hermes Screenshot_1669972703 Simulator Screen Shot - iPhone 14 - 2022-12-02 at 10 22 10

@github-actions github-actions bot added the platform: Android This affects Android label Nov 11, 2022
@tido64 tido64 force-pushed the tido/support-0.71 branch 8 times, most recently from d720ae8 to 75bf6a2 Compare November 18, 2022 12:36
@tido64 tido64 force-pushed the tido/support-0.71 branch 5 times, most recently from 929f8e3 to 9d1ecd0 Compare December 1, 2022 15:25
@tido64 tido64 force-pushed the tido/support-0.71 branch 3 times, most recently from ff5581e to b9e1134 Compare December 5, 2022 14:32
@tido64 tido64 force-pushed the tido/support-0.71 branch from b9e1134 to 07230c1 Compare January 2, 2023 14:43
@github-actions github-actions bot added platform: iOS This affects iOS platform: macOS This affects macOS labels Jan 2, 2023
When upgrading to this version, please update your `build.gradle` to
using `getReactNativeDependencies()`. This will reduce breakages when
moving to 0.71 and beyond:

```diff
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 984a681..29ef8ce 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,7 +1,6 @@
 buildscript {
     def androidTestAppDir = "../node_modules/react-native-test-app/android"
     apply(from: "${androidTestAppDir}/dependencies.gradle")
-    apply(from: "${androidTestAppDir}/test-app-util.gradle")

     repositories {
         mavenCentral()
@@ -9,12 +8,8 @@ buildscript {
     }

     dependencies {
-        classpath("com.android.tools.build:gradle:${androidPluginVersion}")
-
-        def isNightly = getPackageVersionNumber("react-native", rootDir) == 0
-        if (isNightly || isNewArchitectureEnabled(project)) {
-            classpath("com.facebook.react:react-native-gradle-plugin")
-            classpath("de.undercouch:gradle-download-task:5.3.0")
+        getReactNativeDependencies().each { dependency ->
+            classpath(dependency)
         }
     }
 }
```
@tido64 tido64 force-pushed the tido/support-0.71 branch from 07230c1 to 5469a1d Compare January 2, 2023 14:52
@tido64 tido64 requested review from afoxman and kelset January 2, 2023 15:02
@tido64 tido64 marked this pull request as ready for review January 2, 2023 15:02
// Due to a bug in AGP, we have to explicitly set a dependency
// between configureCMakeDebug* tasks and the preBuild tasks. This can
// be removed once this issue is resolved:
// https://issuetracker.google.com/issues/207403732
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be fixed in AGP 7.3.0-alpha9; since 0.71 uses AGP 7.3.1 should we have a separate if statement for 7100?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting with 7100, usePrefabs is true, so we won't go into this path any longer. Eventually, we will just remove this branch.

Copy link
Contributor

@kelset kelset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, tested locally and seems to be working fine - left one minor comment but I think overall we can proceed ✅ :shipit:

@tido64 tido64 merged commit e3217a3 into trunk Jan 4, 2023
@tido64 tido64 deleted the tido/support-0.71 branch January 4, 2023 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Android This affects Android platform: iOS This affects iOS platform: macOS This affects macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for react-native 0.71
2 participants