@@ -5,23 +5,30 @@ | |||
| 5 | "scripts": { | 5 | "scripts": { |
| 6 | "android": "react-native run-android", | 6 | "android": "react-native run-android", |
| 7 | "ios": "react-native run-ios", | 7 | "ios": "react-native run-ios", |
| 8 | "lint": "eslint .", | ||
| 8 | "start": "react-native start", | 9 | "start": "react-native start", |
| 9 | "test": "jest", | ||
| 10 | "lint": "eslint ." | 10 | "test": "jest" |
| 11 | }, | 11 | }, |
| 12 | "dependencies": { | 12 | "dependencies": { |
| 13 | "react": "18.1.0", | ||
| 14 | "react-native": "0.70.15" | 13 | "react": "18.2.0", |
| 14 | "react-native": "0.71.18" | ||
| 15 | }, | 15 | }, |
| 16 | "devDependencies": { | 16 | "devDependencies": { |
| 17 | "@babel/core": "^7.12.9", | ||
| 18 | "@babel/runtime": "^7.12.5", | ||
| 19 | "@react-native-community/eslint-config": "^2.0.0", | ||
| 20 | "babel-jest": "^26.6.3", | ||
| 21 | "eslint": "^7.32.0", | ||
| 22 | "jest": "^26.6.3", | ||
| 23 | "metro-react-native-babel-preset": "0.72.4", | ||
| 24 | "react-test-renderer": "18.1.0" | 17 | "@babel/core": "^7.20.0", |
| 18 | "@babel/preset-env": "^7.20.0", | ||
| 19 | "@babel/runtime": "^7.20.0", | ||
| 20 | "@react-native-community/eslint-config": "^3.2.0", | ||
| 21 | "@tsconfig/react-native": "^2.0.2", | ||
| 22 | "@types/jest": "^29.2.1", | ||
| 23 | "@types/react": "^18.0.24", | ||
| 24 | "@types/react-test-renderer": "^18.0.0", | ||
| 25 | "babel-jest": "^29.2.1", | ||
| 26 | "eslint": "^8.19.0", | ||
| 27 | "jest": "^29.2.1", | ||
| 28 | "metro-react-native-babel-preset": "0.73.10", | ||
| 29 | "prettier": "^2.4.1", | ||
| 30 | "react-test-renderer": "18.2.0", | ||
| 31 | "typescript": "4.8.4" | ||
| 25 | }, | 32 | }, |
| 26 | "jest": { | 33 | "jest": { |
| 27 | "preset": "react-native" | 34 | "preset": "react-native" |
@@ -31,6 +31,8 @@ local.properties | |||
| 31 | *.iml | 31 | *.iml |
| 32 | *.hprof | 32 | *.hprof |
| 33 | .cxx/ | 33 | .cxx/ |
| 34 | *.keystore | ||
| 35 | !debug.keystore | ||
| 34 | 36 | ||
| 35 | # node.js | 37 | # node.js |
| 36 | # | 38 | # |
@@ -38,12 +40,6 @@ node_modules/ | |||
| 38 | npm-debug.log | 40 | npm-debug.log |
| 39 | yarn-error.log | 41 | yarn-error.log |
| 40 | 42 | ||
| 41 | # BUCK | ||
| 42 | buck-out/ | ||
| 43 | \.buckd/ | ||
| 44 | *.keystore | ||
| 45 | !debug.keystore | ||
| 46 | |||
| 47 | # fastlane | 43 | # fastlane |
| 48 | # | 44 | # |
| 49 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | 45 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the |
@@ -62,3 +58,6 @@ buck-out/ | |||
| 62 | # Ruby / CocoaPods | 58 | # Ruby / CocoaPods |
| 63 | /ios/Pods/ | 59 | /ios/Pods/ |
| 64 | /vendor/bundle/ | 60 | /vendor/bundle/ |
| 61 | |||
| 62 | # Temporary files created by Metro to check the health of the file watcher | ||
| 63 | .metro-health-check* | ||
@@ -1 +1 @@ | |||
| 1 | 16 | 1 | 18 |
@@ -3,11 +3,10 @@ | |||
| 3 | * https://github.com/facebook/react-native | 3 | * https://github.com/facebook/react-native |
| 4 | * | 4 | * |
| 5 | * @format | 5 | * @format |
| 6 | * @flow strict-local | ||
| 7 | */ | 6 | */ |
| 8 | 7 | ||
| 9 | import React from 'react'; | 8 | import React from 'react'; |
| 10 | import type {Node} from 'react'; | 9 | import type {PropsWithChildren} from 'react'; |
| 11 | import { | 10 | import { |
| 12 | SafeAreaView, | 11 | SafeAreaView, |
| 13 | ScrollView, | 12 | ScrollView, |
@@ -26,9 +25,11 @@ import { | |||
| 26 | ReloadInstructions, | 25 | ReloadInstructions, |
| 27 | } from 'react-native/Libraries/NewAppScreen'; | 26 | } from 'react-native/Libraries/NewAppScreen'; |
| 28 | 27 | ||
| 29 | /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's | ||
| 30 | * LTI update could not be added via codemod */ | ||
| 31 | const Section = ({children, title}): Node => { | 28 | type SectionProps = PropsWithChildren<{ |
| 29 | title: string; | ||
| 30 | }>; | ||
| 31 | |||
| 32 | function Section({children, title}: SectionProps): JSX.Element { | ||
| 32 | const isDarkMode = useColorScheme() === 'dark'; | 33 | const isDarkMode = useColorScheme() === 'dark'; |
| 33 | return ( | 34 | return ( |
| 34 | <View style={styles.sectionContainer}> | 35 | <View style={styles.sectionContainer}> |
@@ -52,9 +53,9 @@ const Section = ({children, title}): Node => { | |||
| 52 | </Text> | 53 | </Text> |
| 53 | </View> | 54 | </View> |
| 54 | ); | 55 | ); |
| 55 | }; | 56 | } |
| 56 | 57 | ||
| 57 | const App: () => Node = () => { | 58 | function App(): JSX.Element { |
| 58 | const isDarkMode = useColorScheme() === 'dark'; | 59 | const isDarkMode = useColorScheme() === 'dark'; |
| 59 | 60 | ||
| 60 | const backgroundStyle = { | 61 | const backgroundStyle = { |
@@ -76,7 +77,7 @@ const App: () => Node = () => { | |||
| 76 | backgroundColor: isDarkMode ? Colors.black : Colors.white, | 77 | backgroundColor: isDarkMode ? Colors.black : Colors.white, |
| 77 | }}> | 78 | }}> |
| 78 | <Section title="Step One"> | 79 | <Section title="Step One"> |
| 79 | Edit <Text style={styles.highlight}>App.js</Text> to change this | 80 | Edit <Text style={styles.highlight}>App.tsx</Text> to change this |
| 80 | screen and then come back to see your edits. | 81 | screen and then come back to see your edits. |
| 81 | </Section> | 82 | </Section> |
| 82 | <Section title="See Your Changes"> | 83 | <Section title="See Your Changes"> |
@@ -93,7 +94,7 @@ const App: () => Node = () => { | |||
| 93 | </ScrollView> | 94 | </ScrollView> |
| 94 | </SafeAreaView> | 95 | </SafeAreaView> |
| 95 | ); | 96 | ); |
| 96 | }; | 97 | } |
| 97 | 98 | ||
| 98 | const styles = StyleSheet.create({ | 99 | const styles = StyleSheet.create({ |
| 99 | sectionContainer: { | 100 | sectionContainer: { |
@@ -3,5 +3,7 @@ source 'https://rubygems.org' | |||
| 3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version | 3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version |
| 4 | ruby '>= 2.6.10' | 4 | ruby '>= 2.6.10' |
| 5 | 5 | ||
| 6 | gem 'cocoapods', '>= 1.11.3' | 6 | # Cocoapods 1.15 introduced a bug which break the build. We will remove the upper |
| 7 | # bound in the template on Cocoapods with next React Native release. | ||
| 8 | gem 'cocoapods', '>= 1.13', '< 1.15' | ||
| 7 | gem 'activesupport', '>= 6.1.7.3', '< 7.1.0' | 9 | gem 'activesupport', '>= 6.1.7.3', '< 7.1.0' |
@@ -1,106 +1,72 @@ | |||
| 1 | apply plugin: "com.android.application" | 1 | apply plugin: "com.android.application" |
| 2 | apply plugin: "com.facebook.react" | ||
| 2 | 3 | ||
| 3 | import com.android.build.OutputFile | 4 | import com.android.build.OutputFile |
| 4 | import org.apache.tools.ant.taskdefs.condition.Os | ||
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| 7 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets | ||
| 8 | * and bundleReleaseJsAndAssets). | ||
| 9 | * These basically call `react-native bundle` with the correct arguments during the Android build | ||
| 10 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the | ||
| 11 | * bundle directly from the development server. Below you can see all the possible configurations | ||
| 12 | * and their defaults. If you decide to add a configuration block, make sure to add it before the | ||
| 13 | * `apply from: "../../node_modules/react-native/react.gradle"` line. | ||
| 14 | * | ||
| 15 | * project.ext.react = [ | ||
| 16 | * // the name of the generated asset file containing your JS bundle | ||
| 17 | * bundleAssetName: "index.android.bundle", | ||
| 18 | * | ||
| 19 | * // the entry file for bundle generation. If none specified and | ||
| 20 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is | ||
| 21 | * // default. Can be overridden with ENTRY_FILE environment variable. | ||
| 22 | * entryFile: "index.android.js", | ||
| 23 | * | ||
| 24 | * // https://reactnative.dev/docs/performance#enable-the-ram-format | ||
| 25 | * bundleCommand: "ram-bundle", | ||
| 26 | * | ||
| 27 | * // whether to bundle JS and assets in debug mode | ||
| 28 | * bundleInDebug: false, | ||
| 29 | * | ||
| 30 | * // whether to bundle JS and assets in release mode | ||
| 31 | * bundleInRelease: true, | ||
| 32 | * | ||
| 33 | * // whether to bundle JS and assets in another build variant (if configured). | ||
| 34 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants | ||
| 35 | * // The configuration property can be in the following formats | ||
| 36 | * // 'bundleIn${productFlavor}${buildType}' | ||
| 37 | * // 'bundleIn${buildType}' | ||
| 38 | * // bundleInFreeDebug: true, | ||
| 39 | * // bundleInPaidRelease: true, | ||
| 40 | * // bundleInBeta: true, | ||
| 41 | * | ||
| 42 | * // whether to disable dev mode in custom build variants (by default only disabled in release) | ||
| 43 | * // for example: to disable dev mode in the staging build type (if configured) | ||
| 44 | * devDisabledInStaging: true, | ||
| 45 | * // The configuration property can be in the following formats | ||
| 46 | * // 'devDisabledIn${productFlavor}${buildType}' | ||
| 47 | * // 'devDisabledIn${buildType}' | ||
| 48 | * | ||
| 49 | * // the root of your project, i.e. where "package.json" lives | ||
| 50 | * root: "../../", | ||
| 51 | * | ||
| 52 | * // where to put the JS bundle asset in debug mode | ||
| 53 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", | ||
| 54 | * | ||
| 55 | * // where to put the JS bundle asset in release mode | ||
| 56 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", | ||
| 57 | * | ||
| 58 | * // where to put drawable resources / React Native assets, e.g. the ones you use via | ||
| 59 | * // require('./image.png')), in debug mode | ||
| 60 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", | ||
| 61 | * | ||
| 62 | * // where to put drawable resources / React Native assets, e.g. the ones you use via | ||
| 63 | * // require('./image.png')), in release mode | ||
| 64 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", | ||
| 65 | * | ||
| 66 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means | ||
| 67 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to | ||
| 68 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle | ||
| 69 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ | ||
| 70 | * // for example, you might want to remove it from here. | ||
| 71 | * inputExcludes: ["android/**", "ios/**"], | ||
| 72 | * | ||
| 73 | * // override which node gets called and with what additional arguments | ||
| 74 | * nodeExecutableAndArgs: ["node"], | ||
| 75 | * | ||
| 76 | * // supply additional arguments to the packager | ||
| 77 | * extraPackagerArgs: [] | ||
| 78 | * ] | 7 | * This is the configuration block to customize your React Native Android app. |
| 8 | * By default you don't need to apply any configuration, just uncomment the lines you need. | ||
| 79 | */ | 9 | */ |
| 80 | |||
| 81 | project.ext.react = [ | ||
| 82 | enableHermes: true, // clean and rebuild if changing | ||
| 83 | ] | ||
| 84 | |||
| 85 | apply from: "../../node_modules/react-native/react.gradle" | 10 | react { |
| 11 | /* Folders */ | ||
| 12 | // The root of your project, i.e. where "package.json" lives. Default is '..' | ||
| 13 | // root = file("../") | ||
| 14 | // The folder where the react-native NPM package is. Default is ../node_modules/react-native | ||
| 15 | // reactNativeDir = file("../node_modules/react-native") | ||
| 16 | // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen | ||
| 17 | // codegenDir = file("../node_modules/react-native-codegen") | ||
| 18 | // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js | ||
| 19 | // cliFile = file("../node_modules/react-native/cli.js") | ||
| 20 | |||
| 21 | /* Variants */ | ||
| 22 | // The list of variants to that are debuggable. For those we're going to | ||
| 23 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'. | ||
| 24 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. | ||
| 25 | // debuggableVariants = ["liteDebug", "prodDebug"] | ||
| 26 | |||
| 27 | /* Bundling */ | ||
| 28 | // A list containing the node command and its flags. Default is just 'node'. | ||
| 29 | // nodeExecutableAndArgs = ["node"] | ||
| 30 | // | ||
| 31 | // The command to run when bundling. By default is 'bundle' | ||
| 32 | // bundleCommand = "ram-bundle" | ||
| 33 | // | ||
| 34 | // The path to the CLI configuration file. Default is empty. | ||
| 35 | // bundleConfig = file(../rn-cli.config.js) | ||
| 36 | // | ||
| 37 | // The name of the generated asset file containing your JS bundle | ||
| 38 | // bundleAssetName = "MyApplication.android.bundle" | ||
| 39 | // | ||
| 40 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' | ||
| 41 | // entryFile = file("../js/MyApplication.android.js") | ||
| 42 | // | ||
| 43 | // A list of extra flags to pass to the 'bundle' commands. | ||
| 44 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle | ||
| 45 | // extraPackagerArgs = [] | ||
| 46 | |||
| 47 | /* Hermes Commands */ | ||
| 48 | // The hermes compiler command to run. By default it is 'hermesc' | ||
| 49 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" | ||
| 50 | // | ||
| 51 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" | ||
| 52 | // hermesFlags = ["-O", "-output-source-map"] | ||
| 53 | } | ||
| 86 | 54 | ||
| 87 | /** | 55 | /** |
| 88 | * Set this to true to create two separate APKs instead of one: | ||
| 89 | * - An APK that only works on ARM devices | ||
| 90 | * - An APK that only works on x86 devices | ||
| 91 | * The advantage is the size of the APK is reduced by about 4MB. | ||
| 92 | * Upload all the APKs to the Play Store and people will download | ||
| 93 | * the correct one based on the CPU architecture of their device. | 56 | * Set this to true to create four separate APKs instead of one, |
| 57 | * one for each native architecture. This is useful if you don't | ||
| 58 | * use App Bundles (https://developer.android.com/guide/app-bundle/) | ||
| 59 | * and want to have separate APKs to upload to the Play Store. | ||
| 94 | */ | 60 | */ |
| 95 | def enableSeparateBuildPerCPUArchitecture = false | 61 | def enableSeparateBuildPerCPUArchitecture = false |
| 96 | 62 | ||
| 97 | /** | 63 | /** |
| 98 | * Run Proguard to shrink the Java bytecode in release builds. | 64 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode. |
| 99 | */ | 65 | */ |
| 100 | def enableProguardInReleaseBuilds = false | 66 | def enableProguardInReleaseBuilds = false |
| 101 | 67 | ||
| 102 | /** | 68 | /** |
| 103 | * The preferred build flavor of JavaScriptCore. | 69 | * The preferred build flavor of JavaScriptCore (JSC) |
| 104 | * | 70 | * |
| 105 | * For example, to use the international variant, you can use: | 71 | * For example, to use the international variant, you can use: |
| 106 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` | 72 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` |
@@ -113,16 +79,9 @@ def enableProguardInReleaseBuilds = false | |||
| 113 | def jscFlavor = 'org.webkit:android-jsc:+' | 79 | def jscFlavor = 'org.webkit:android-jsc:+' |
| 114 | 80 | ||
| 115 | /** | 81 | /** |
| 116 | * Whether to enable the Hermes VM. | ||
| 117 | * | ||
| 118 | * This should be set on project.ext.react and that value will be read here. If it is not set | ||
| 119 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode | ||
| 120 | * and the benefits of using Hermes will therefore be sharply reduced. | ||
| 121 | */ | ||
| 122 | def enableHermes = project.ext.react.get("enableHermes", false); | ||
| 123 | |||
| 124 | /** | ||
| 125 | * Architectures to build native code for. | 82 | * Private function to get the list of Native Architectures you want to build. |
| 83 | * This reads the value from reactNativeArchitectures in your gradle.properties | ||
| 84 | * file and works together with the --active-arch-only flag of react-native run-android. | ||
| 126 | */ | 85 | */ |
| 127 | def reactNativeArchitectures() { | 86 | def reactNativeArchitectures() { |
| 128 | def value = project.getProperties().get("reactNativeArchitectures") | 87 | def value = project.getProperties().get("reactNativeArchitectures") |
@@ -134,72 +93,13 @@ android { | |||
| 134 | 93 | ||
| 135 | compileSdkVersion rootProject.ext.compileSdkVersion | 94 | compileSdkVersion rootProject.ext.compileSdkVersion |
| 136 | 95 | ||
| 96 | namespace "com.rndiffapp" | ||
| 137 | defaultConfig { | 97 | defaultConfig { |
| 138 | applicationId "com.rndiffapp" | 98 | applicationId "com.rndiffapp" |
| 139 | minSdkVersion rootProject.ext.minSdkVersion | 99 | minSdkVersion rootProject.ext.minSdkVersion |
| 140 | targetSdkVersion rootProject.ext.targetSdkVersion | 100 | targetSdkVersion rootProject.ext.targetSdkVersion |
| 141 | versionCode 1 | 101 | versionCode 1 |
| 142 | versionName "1.0" | 102 | versionName "1.0" |
| 143 | buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() | ||
| 144 | |||
| 145 | if (isNewArchitectureEnabled()) { | ||
| 146 | // We configure the CMake build only if you decide to opt-in for the New Architecture. | ||
| 147 | externalNativeBuild { | ||
| 148 | cmake { | ||
| 149 | arguments "-DPROJECT_BUILD_DIR=$buildDir", | ||
| 150 | "-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid", | ||
| 151 | "-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build", | ||
| 152 | "-DNODE_MODULES_DIR=$rootDir/../node_modules", | ||
| 153 | "-DANDROID_STL=c++_shared" | ||
| 154 | } | ||
| 155 | } | ||
| 156 | if (!enableSeparateBuildPerCPUArchitecture) { | ||
| 157 | ndk { | ||
| 158 | abiFilters (*reactNativeArchitectures()) | ||
| 159 | } | ||
| 160 | } | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | if (isNewArchitectureEnabled()) { | ||
| 165 | // We configure the NDK build only if you decide to opt-in for the New Architecture. | ||
| 166 | externalNativeBuild { | ||
| 167 | cmake { | ||
| 168 | path "$projectDir/src/main/jni/CMakeLists.txt" | ||
| 169 | } | ||
| 170 | } | ||
| 171 | def reactAndroidProjectDir = project(':ReactAndroid').projectDir | ||
| 172 | def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) { | ||
| 173 | dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck") | ||
| 174 | from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") | ||
| 175 | into("$buildDir/react-ndk/exported") | ||
| 176 | } | ||
| 177 | def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) { | ||
| 178 | dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck") | ||
| 179 | from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") | ||
| 180 | into("$buildDir/react-ndk/exported") | ||
| 181 | } | ||
| 182 | afterEvaluate { | ||
| 183 | // If you wish to add a custom TurboModule or component locally, | ||
| 184 | // you should uncomment this line. | ||
| 185 | // preBuild.dependsOn("generateCodegenArtifactsFromSchema") | ||
| 186 | preDebugBuild.dependsOn(packageReactNdkDebugLibs) | ||
| 187 | preReleaseBuild.dependsOn(packageReactNdkReleaseLibs) | ||
| 188 | |||
| 189 | // Due to a bug inside AGP, we have to explicitly set a dependency | ||
| 190 | // between configureCMakeDebug* tasks and the preBuild tasks. | ||
| 191 | // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732 | ||
| 192 | configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild) | ||
| 193 | configureCMakeDebug.dependsOn(preDebugBuild) | ||
| 194 | reactNativeArchitectures().each { architecture -> | ||
| 195 | tasks.findByName("configureCMakeDebug[${architecture}]")?.configure { | ||
| 196 | dependsOn("preDebugBuild") | ||
| 197 | } | ||
| 198 | tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure { | ||
| 199 | dependsOn("preReleaseBuild") | ||
| 200 | } | ||
| 201 | } | ||
| 202 | } | ||
| 203 | } | 103 | } |
| 204 | 104 | ||
| 205 | splits { | 105 | splits { |
@@ -249,65 +149,22 @@ android { | |||
| 249 | } | 149 | } |
| 250 | 150 | ||
| 251 | dependencies { | 151 | dependencies { |
| 252 | implementation fileTree(dir: "libs", include: ["*.jar"]) | ||
| 253 | |||
| 254 | //noinspection GradleDynamicVersion | ||
| 255 | implementation "com.facebook.react:react-native:+" // From node_modules | 152 | // The version of react-native is set by the React Native Gradle Plugin |
| 153 | implementation("com.facebook.react:react-android") | ||
| 256 | 154 | ||
| 257 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" | ||
| 258 | |||
| 259 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { | ||
| 260 | exclude group:'com.facebook.fbjni' | ||
| 261 | } | 155 | implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") |
| 262 | 156 | ||
| 157 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") | ||
| 263 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { | 158 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { |
| 264 | exclude group:'com.facebook.flipper' | ||
| 265 | exclude group:'com.squareup.okhttp3', module:'okhttp' | 159 | exclude group:'com.squareup.okhttp3', module:'okhttp' |
| 266 | } | 160 | } |
| 267 | 161 | ||
| 268 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { | ||
| 269 | exclude group:'com.facebook.flipper' | ||
| 270 | } | ||
| 271 | |||
| 272 | if (enableHermes) { | ||
| 273 | //noinspection GradleDynamicVersion | ||
| 274 | implementation("com.facebook.react:hermes-engine:+") { // From node_modules | ||
| 275 | exclude group:'com.facebook.fbjni' | ||
| 276 | } | 162 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") |
| 163 | if (hermesEnabled.toBoolean()) { | ||
| 164 | implementation("com.facebook.react:hermes-android") | ||
| 277 | } else { | 165 | } else { |
| 278 | implementation jscFlavor | 166 | implementation jscFlavor |
| 279 | } | 167 | } |
| 280 | } | 168 | } |
| 281 | 169 | ||
| 282 | if (isNewArchitectureEnabled()) { | ||
| 283 | // If new architecture is enabled, we let you build RN from source | ||
| 284 | // Otherwise we fallback to a prebuilt .aar bundled in the NPM package. | ||
| 285 | // This will be applied to all the imported transtitive dependency. | ||
| 286 | configurations.all { | ||
| 287 | resolutionStrategy.dependencySubstitution { | ||
| 288 | substitute(module("com.facebook.react:react-native")) | ||
| 289 | .using(project(":ReactAndroid")) | ||
| 290 | .because("On New Architecture we're building React Native from source") | ||
| 291 | substitute(module("com.facebook.react:hermes-engine")) | ||
| 292 | .using(project(":ReactAndroid:hermes-engine")) | ||
| 293 | .because("On New Architecture we're building Hermes from source") | ||
| 294 | } | ||
| 295 | } | ||
| 296 | } | ||
| 297 | |||
| 298 | // Run this once to be able to run the application with BUCK | ||
| 299 | // puts all compile dependencies into folder libs for BUCK to use | ||
| 300 | task copyDownloadableDepsToLibs(type: Copy) { | ||
| 301 | from configurations.implementation | ||
| 302 | into 'libs' | ||
| 303 | } | ||
| 304 | |||
| 305 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) | 170 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) |
| 306 | |||
| 307 | def isNewArchitectureEnabled() { | ||
| 308 | // To opt-in for the New Architecture, you can either: | ||
| 309 | // - Set `newArchEnabled` to true inside the `gradle.properties` file | ||
| 310 | // - Invoke gradle with `-newArchEnabled=true` | ||
| 311 | // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` | ||
| 312 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" | ||
| 313 | } | ||
@@ -17,7 +17,6 @@ import com.facebook.flipper.plugins.inspector.DescriptorMapping; | |||
| 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; | 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; |
| 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; | 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; |
| 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; | 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; |
| 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; | ||
| 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; | 20 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; |
| 22 | import com.facebook.react.ReactInstanceEventListener; | 21 | import com.facebook.react.ReactInstanceEventListener; |
| 23 | import com.facebook.react.ReactInstanceManager; | 22 | import com.facebook.react.ReactInstanceManager; |
@@ -25,13 +24,16 @@ import com.facebook.react.bridge.ReactContext; | |||
| 25 | import com.facebook.react.modules.network.NetworkingModule; | 24 | import com.facebook.react.modules.network.NetworkingModule; |
| 26 | import okhttp3.OkHttpClient; | 25 | import okhttp3.OkHttpClient; |
| 27 | 26 | ||
| 27 | /** | ||
| 28 | * Class responsible of loading Flipper inside your React Native application. This is the debug | ||
| 29 | * flavor of it. Here you can add your own plugins and customize the Flipper setup. | ||
| 30 | */ | ||
| 28 | public class ReactNativeFlipper { | 31 | public class ReactNativeFlipper { |
| 29 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { | 32 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { |
| 30 | if (FlipperUtils.shouldEnableFlipper(context)) { | 33 | if (FlipperUtils.shouldEnableFlipper(context)) { |
| 31 | final FlipperClient client = AndroidFlipperClient.getInstance(context); | 34 | final FlipperClient client = AndroidFlipperClient.getInstance(context); |
| 32 | 35 | ||
| 33 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); | 36 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); |
| 34 | client.addPlugin(new ReactFlipperPlugin()); | ||
| 35 | client.addPlugin(new DatabasesFlipperPlugin(context)); | 37 | client.addPlugin(new DatabasesFlipperPlugin(context)); |
| 36 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); | 38 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); |
| 37 | client.addPlugin(CrashReporterPlugin.getInstance()); | 39 | client.addPlugin(CrashReporterPlugin.getInstance()); |
@@ -1,5 +1,4 @@ | |||
| 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | package="com.rndiffapp"> | 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android"> |
| 3 | 2 | ||
| 4 | <uses-permission android:name="android.permission.INTERNET" /> | 3 | <uses-permission android:name="android.permission.INTERNET" /> |
| 5 | 4 | ||
@@ -2,7 +2,8 @@ package com.rndiffapp; | |||
| 2 | 2 | ||
| 3 | import com.facebook.react.ReactActivity; | 3 | import com.facebook.react.ReactActivity; |
| 4 | import com.facebook.react.ReactActivityDelegate; | 4 | import com.facebook.react.ReactActivityDelegate; |
| 5 | import com.facebook.react.ReactRootView; | 5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; |
| 6 | import com.facebook.react.defaults.DefaultReactActivityDelegate; | ||
| 6 | 7 | ||
| 7 | public class MainActivity extends ReactActivity { | 8 | public class MainActivity extends ReactActivity { |
| 8 | 9 | ||
@@ -16,33 +17,19 @@ public class MainActivity extends ReactActivity { | |||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | /** | 19 | /** |
| 19 | * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and | ||
| 20 | * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer | ||
| 21 | * (Paper). | 20 | * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link |
| 21 | * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React | ||
| 22 | * (aka React 18) with two boolean flags. | ||
| 22 | */ | 23 | */ |
| 23 | @Override | 24 | @Override |
| 24 | protected ReactActivityDelegate createReactActivityDelegate() { | 25 | protected ReactActivityDelegate createReactActivityDelegate() { |
| 25 | return new MainActivityDelegate(this, getMainComponentName()); | ||
| 26 | } | ||
| 27 | |||
| 28 | public static class MainActivityDelegate extends ReactActivityDelegate { | ||
| 29 | public MainActivityDelegate(ReactActivity activity, String mainComponentName) { | ||
| 30 | super(activity, mainComponentName); | ||
| 31 | } | ||
| 32 | |||
| 33 | @Override | ||
| 34 | protected ReactRootView createRootView() { | ||
| 35 | ReactRootView reactRootView = new ReactRootView(getContext()); | 26 | return new DefaultReactActivityDelegate( |
| 27 | this, | ||
| 28 | getMainComponentName(), | ||
| 36 | // If you opted-in for the New Architecture, we enable the Fabric Renderer. | 29 | // If you opted-in for the New Architecture, we enable the Fabric Renderer. |
| 37 | reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED); | ||
| 38 | return reactRootView; | ||
| 39 | } | ||
| 40 | |||
| 41 | @Override | ||
| 42 | protected boolean isConcurrentRootEnabled() { | ||
| 43 | // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18). | ||
| 44 | // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html | ||
| 45 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; | ||
| 46 | } | 30 | DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled |
| 31 | // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18). | ||
| 32 | DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled | ||
| 33 | ); | ||
| 47 | } | 34 | } |
| 48 | } | 35 | } |
@@ -1,22 +1,19 @@ | |||
| 1 | package com.rndiffapp; | 1 | package com.rndiffapp; |
| 2 | 2 | ||
| 3 | import android.app.Application; | 3 | import android.app.Application; |
| 4 | import android.content.Context; | ||
| 5 | import com.facebook.react.PackageList; | 4 | import com.facebook.react.PackageList; |
| 6 | import com.facebook.react.ReactApplication; | 5 | import com.facebook.react.ReactApplication; |
| 7 | import com.facebook.react.ReactInstanceManager; | ||
| 8 | import com.facebook.react.ReactNativeHost; | 6 | import com.facebook.react.ReactNativeHost; |
| 9 | import com.facebook.react.ReactPackage; | 7 | import com.facebook.react.ReactPackage; |
| 10 | import com.facebook.react.config.ReactFeatureFlags; | 8 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; |
| 9 | import com.facebook.react.defaults.DefaultReactNativeHost; | ||
| 11 | import com.facebook.soloader.SoLoader; | 10 | import com.facebook.soloader.SoLoader; |
| 12 | import com.rndiffapp.newarchitecture.MainApplicationReactNativeHost; | ||
| 13 | import java.lang.reflect.InvocationTargetException; | ||
| 14 | import java.util.List; | 11 | import java.util.List; |
| 15 | 12 | ||
| 16 | public class MainApplication extends Application implements ReactApplication { | 13 | public class MainApplication extends Application implements ReactApplication { |
| 17 | 14 | ||
| 18 | private final ReactNativeHost mReactNativeHost = | 15 | private final ReactNativeHost mReactNativeHost = |
| 19 | new ReactNativeHost(this) { | 16 | new DefaultReactNativeHost(this) { |
| 20 | @Override | 17 | @Override |
| 21 | public boolean getUseDeveloperSupport() { | 18 | public boolean getUseDeveloperSupport() { |
| 22 | return BuildConfig.DEBUG; | 19 | return BuildConfig.DEBUG; |
@@ -35,57 +32,31 @@ public class MainApplication extends Application implements ReactApplication { | |||
| 35 | protected String getJSMainModuleName() { | 32 | protected String getJSMainModuleName() { |
| 36 | return "index"; | 33 | return "index"; |
| 37 | } | 34 | } |
| 38 | }; | ||
| 39 | 35 | ||
| 40 | private final ReactNativeHost mNewArchitectureNativeHost = | ||
| 41 | new MainApplicationReactNativeHost(this); | 36 | @Override |
| 37 | protected boolean isNewArchEnabled() { | ||
| 38 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; | ||
| 39 | } | ||
| 40 | |||
| 41 | @Override | ||
| 42 | protected Boolean isHermesEnabled() { | ||
| 43 | return BuildConfig.IS_HERMES_ENABLED; | ||
| 44 | } | ||
| 45 | }; | ||
| 42 | 46 | ||
| 43 | @Override | 47 | @Override |
| 44 | public ReactNativeHost getReactNativeHost() { | 48 | public ReactNativeHost getReactNativeHost() { |
| 45 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { | ||
| 46 | return mNewArchitectureNativeHost; | ||
| 47 | } else { | ||
| 48 | return mReactNativeHost; | 49 | return mReactNativeHost; |
| 49 | } | 50 | } |
| 50 | } | ||
| 51 | 51 | ||
| 52 | @Override | 52 | @Override |
| 53 | public void onCreate() { | 53 | public void onCreate() { |
| 54 | super.onCreate(); | 54 | super.onCreate(); |
| 55 | // If you opted-in for the New Architecture, we enable the TurboModule system | ||
| 56 | ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; | ||
| 57 | SoLoader.init(this, /* native exopackage */ false); | 55 | SoLoader.init(this, /* native exopackage */ false); |
| 58 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); | ||
| 59 | } | ||
| 60 | |||
| 61 | /** | ||
| 62 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like | ||
| 63 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); | ||
| 64 | * | ||
| 65 | * @param context | ||
| 66 | * @param reactInstanceManager | ||
| 67 | */ | ||
| 68 | private static void initializeFlipper( | ||
| 69 | Context context, ReactInstanceManager reactInstanceManager) { | ||
| 70 | if (BuildConfig.DEBUG) { | ||
| 71 | try { | ||
| 72 | /* | ||
| 73 | We use reflection here to pick up the class that initializes Flipper, | ||
| 74 | since Flipper library is not available in release mode | ||
| 75 | */ | ||
| 76 | Class<?> aClass = Class.forName("com.rndiffapp.ReactNativeFlipper"); | ||
| 77 | aClass | ||
| 78 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) | ||
| 79 | .invoke(null, context, reactInstanceManager); | ||
| 80 | } catch (ClassNotFoundException e) { | ||
| 81 | e.printStackTrace(); | ||
| 82 | } catch (NoSuchMethodException e) { | ||
| 83 | e.printStackTrace(); | ||
| 84 | } catch (IllegalAccessException e) { | ||
| 85 | e.printStackTrace(); | ||
| 86 | } catch (InvocationTargetException e) { | ||
| 87 | e.printStackTrace(); | ||
| 88 | } | 56 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { |
| 57 | // If you opted-in for the New Architecture, we load the native entry point for this app. | ||
| 58 | DefaultNewArchitectureEntryPoint.load(); | ||
| 89 | } | 59 | } |
| 60 | ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); | ||
| 90 | } | 61 | } |
| 91 | } | 62 | } |
@@ -0,0 +1,20 @@ | |
| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * <p>This source code is licensed under the MIT license found in the LICENSE file in the root |
| 5 | * directory of this source tree. |
| 6 | */ |
| 7 | package com.rndiffapp; |
| 8 | |
| 9 | import android.content.Context; |
| 10 | import com.facebook.react.ReactInstanceManager; |
| 11 | |
| 12 | /** |
| 13 | * Class responsible of loading Flipper inside your React Native application. This is the release |
| 14 | * flavor of it so it's empty as we don't want to load Flipper. |
| 15 | */ |
| 16 | public class ReactNativeFlipper { |
| 17 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { |
| 18 | // Do nothing as we don't want to initialize Flipper on Release. |
| 19 | } |
| 20 | } |
@@ -2,50 +2,20 @@ | |||
| 2 | 2 | ||
| 3 | buildscript { | 3 | buildscript { |
| 4 | ext { | 4 | ext { |
| 5 | buildToolsVersion = "31.0.0" | 5 | buildToolsVersion = "33.0.0" |
| 6 | minSdkVersion = 21 | 6 | minSdkVersion = 21 |
| 7 | compileSdkVersion = 31 | ||
| 8 | targetSdkVersion = 31 | 7 | compileSdkVersion = 33 |
| 8 | targetSdkVersion = 33 | ||
| 9 | 9 | ||
| 10 | if (System.properties['os.arch'] == "aarch64") { | ||
| 11 | // For M1 Users we need to use the NDK 24 which added support for aarch64 | ||
| 12 | ndkVersion = "24.0.8215888" | ||
| 13 | } else { | ||
| 14 | // Otherwise we default to the side-by-side NDK version from AGP. | ||
| 15 | ndkVersion = "21.4.7075529" | ||
| 16 | } | 10 | // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. |
| 11 | ndkVersion = "23.1.7779620" | ||
| 17 | } | 12 | } |
| 18 | repositories { | 13 | repositories { |
| 19 | google() | 14 | google() |
| 20 | mavenCentral() | 15 | mavenCentral() |
| 21 | } | 16 | } |
| 22 | dependencies { | 17 | dependencies { |
| 23 | classpath("com.android.tools.build:gradle:7.2.1") | 18 | classpath("com.android.tools.build:gradle:7.3.1") |
| 24 | classpath("com.facebook.react:react-native-gradle-plugin") | 19 | classpath("com.facebook.react:react-native-gradle-plugin") |
| 25 | classpath("de.undercouch:gradle-download-task:5.0.1") | ||
| 26 | // NOTE: Do not place your application dependencies here; they belong | ||
| 27 | // in the individual module build.gradle files | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | allprojects { | ||
| 32 | repositories { | ||
| 33 | maven { | ||
| 34 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm | ||
| 35 | url("$rootDir/../node_modules/react-native/android") | ||
| 36 | } | ||
| 37 | maven { | ||
| 38 | // Android JSC is installed from npm | ||
| 39 | url("$rootDir/../node_modules/jsc-android/dist") | ||
| 40 | } | ||
| 41 | mavenCentral { | ||
| 42 | // We don't want to fetch react-native from Maven Central as there are | ||
| 43 | // older versions over there. | ||
| 44 | content { | ||
| 45 | excludeGroup "com.facebook.react" | ||
| 46 | } | ||
| 47 | } | ||
| 48 | google() | ||
| 49 | maven { url 'https://www.jitpack.io' } | ||
| 50 | } | 20 | } |
| 51 | } | 21 | } |
@@ -38,3 +38,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 | |||
| 38 | # to write custom TurboModules/Fabric components OR use libraries that | 38 | # to write custom TurboModules/Fabric components OR use libraries that |
| 39 | # are providing them. | 39 | # are providing them. |
| 40 | newArchEnabled=false | 40 | newArchEnabled=false |
| 41 | |||
| 42 | # Use this property to enable or disable the Hermes JS engine. | ||
| 43 | # If set to false, you will be using JSC instead. | ||
| 44 | hermesEnabled=true | ||
@@ -2,10 +2,3 @@ rootProject.name = 'RnDiffApp' | |||
| 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) | 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) |
| 3 | include ':app' | 3 | include ':app' |
| 4 | includeBuild('../node_modules/react-native-gradle-plugin') | 4 | includeBuild('../node_modules/react-native-gradle-plugin') |
| 5 | |||
| 6 | if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { | ||
| 7 | include(":ReactAndroid") | ||
| 8 | project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') | ||
| 9 | include(":ReactAndroid:hermes-engine") | ||
| 10 | project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine') | ||
| 11 | } | ||
@@ -1,8 +1,25 @@ | |||
| 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' | 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' |
| 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' | 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' |
| 3 | 3 | ||
| 4 | platform :ios, '12.4' | ||
| 5 | install! 'cocoapods', :deterministic_uuids => false | 4 | platform :ios, min_ios_version_supported |
| 5 | prepare_react_native_project! | ||
| 6 | |||
| 7 | # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. | ||
| 8 | # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded | ||
| 9 | # | ||
| 10 | # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` | ||
| 11 | # ```js | ||
| 12 | # module.exports = { | ||
| 13 | # dependencies: { | ||
| 14 | # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), | ||
| 15 | # ``` | ||
| 16 | flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled | ||
| 17 | |||
| 18 | linkage = ENV['USE_FRAMEWORKS'] | ||
| 19 | if linkage != nil | ||
| 20 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green | ||
| 21 | use_frameworks! :linkage => linkage.to_sym | ||
| 22 | end | ||
| 6 | 23 | ||
| 7 | target 'RnDiffApp' do | 24 | target 'RnDiffApp' do |
| 8 | config = use_native_modules! | 25 | config = use_native_modules! |
@@ -15,13 +32,13 @@ target 'RnDiffApp' do | |||
| 15 | # Hermes is now enabled by default. Disable by setting this flag to false. | 32 | # Hermes is now enabled by default. Disable by setting this flag to false. |
| 16 | # Upcoming versions of React Native may rely on get_default_flags(), but | 33 | # Upcoming versions of React Native may rely on get_default_flags(), but |
| 17 | # we make it explicit here to aid in the React Native upgrade process. | 34 | # we make it explicit here to aid in the React Native upgrade process. |
| 18 | :hermes_enabled => true, | 35 | :hermes_enabled => flags[:hermes_enabled], |
| 19 | :fabric_enabled => flags[:fabric_enabled], | 36 | :fabric_enabled => flags[:fabric_enabled], |
| 20 | # Enables Flipper. | 37 | # Enables Flipper. |
| 21 | # | 38 | # |
| 22 | # Note that if you have use_frameworks! enabled, Flipper will not work and | 39 | # Note that if you have use_frameworks! enabled, Flipper will not work and |
| 23 | # you should disable the next line. | 40 | # you should disable the next line. |
| 24 | :flipper_configuration => FlipperConfiguration.enabled, | 41 | :flipper_configuration => flipper_config, |
| 25 | # An absolute path to your application root. | 42 | # An absolute path to your application root. |
| 26 | :app_path => "#{Pod::Config.instance.installation_root}/.." | 43 | :app_path => "#{Pod::Config.instance.installation_root}/.." |
| 27 | ) | 44 | ) |
@@ -492,6 +492,7 @@ | |||
| 492 | "$(inherited)", | 492 | "$(inherited)", |
| 493 | "@executable_path/Frameworks", | 493 | "@executable_path/Frameworks", |
| 494 | ); | 494 | ); |
| 495 | MARKETING_VERSION = 1.0; | ||
| 495 | OTHER_LDFLAGS = ( | 496 | OTHER_LDFLAGS = ( |
| 496 | "$(inherited)", | 497 | "$(inherited)", |
| 497 | "-ObjC", | 498 | "-ObjC", |
@@ -517,6 +518,7 @@ | |||
| 517 | "$(inherited)", | 518 | "$(inherited)", |
| 518 | "@executable_path/Frameworks", | 519 | "@executable_path/Frameworks", |
| 519 | ); | 520 | ); |
| 521 | MARKETING_VERSION = 1.0; | ||
| 520 | OTHER_LDFLAGS = ( | 522 | OTHER_LDFLAGS = ( |
| 521 | "$(inherited)", | 523 | "$(inherited)", |
| 522 | "-ObjC", | 524 | "-ObjC", |
@@ -1,8 +1,6 @@ | |||
| 1 | #import <React/RCTBridgeDelegate.h> | 1 | #import <RCTAppDelegate.h> |
| 2 | #import <UIKit/UIKit.h> | 2 | #import <UIKit/UIKit.h> |
| 3 | 3 | ||
| 4 | @interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate> | ||
| 5 | |||
| 6 | @property (nonatomic, strong) UIWindow *window; | 4 | @interface AppDelegate : RCTAppDelegate |
| 7 | 5 | ||
| 8 | @end | 6 | @end |
@@ -1,85 +1,17 @@ | |||
| 1 | #import "AppDelegate.h" | 1 | #import "AppDelegate.h" |
| 2 | 2 | ||
| 3 | #import <React/RCTBridge.h> | ||
| 4 | #import <React/RCTBundleURLProvider.h> | 3 | #import <React/RCTBundleURLProvider.h> |
| 5 | #import <React/RCTRootView.h> | ||
| 6 | |||
| 7 | #import <React/RCTAppSetupUtils.h> | ||
| 8 | |||
| 9 | #if RCT_NEW_ARCH_ENABLED | ||
| 10 | #import <React/CoreModulesPlugins.h> | ||
| 11 | #import <React/RCTCxxBridgeDelegate.h> | ||
| 12 | #import <React/RCTFabricSurfaceHostingProxyRootView.h> | ||
| 13 | #import <React/RCTSurfacePresenter.h> | ||
| 14 | #import <React/RCTSurfacePresenterBridgeAdapter.h> | ||
| 15 | #import <ReactCommon/RCTTurboModuleManager.h> | ||
| 16 | |||
| 17 | #import <react/config/ReactNativeConfig.h> | ||
| 18 | |||
| 19 | static NSString *const kRNConcurrentRoot = @"concurrentRoot"; | ||
| 20 | |||
| 21 | @interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> { | ||
| 22 | RCTTurboModuleManager *_turboModuleManager; | ||
| 23 | RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; | ||
| 24 | std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig; | ||
| 25 | facebook::react::ContextContainer::Shared _contextContainer; | ||
| 26 | } | ||
| 27 | @end | ||
| 28 | #endif | ||
| 29 | 4 | ||
| 30 | @implementation AppDelegate | 5 | @implementation AppDelegate |
| 31 | 6 | ||
| 32 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | 7 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions |
| 33 | { | 8 | { |
| 34 | RCTAppSetupPrepareApp(application); | ||
| 35 | |||
| 36 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; | ||
| 37 | |||
| 38 | #if RCT_NEW_ARCH_ENABLED | ||
| 39 | _contextContainer = std::make_shared<facebook::react::ContextContainer const>(); | ||
| 40 | _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>(); | ||
| 41 | _contextContainer->insert("ReactNativeConfig", _reactNativeConfig); | ||
| 42 | _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer]; | ||
| 43 | bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; | ||
| 44 | #endif | ||
| 45 | |||
| 46 | NSDictionary *initProps = [self prepareInitialProps]; | ||
| 47 | UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"RnDiffApp", initProps); | ||
| 48 | |||
| 49 | if (@available(iOS 13.0, *)) { | ||
| 50 | rootView.backgroundColor = [UIColor systemBackgroundColor]; | ||
| 51 | } else { | ||
| 52 | rootView.backgroundColor = [UIColor whiteColor]; | ||
| 53 | } | ||
| 54 | |||
| 55 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | ||
| 56 | UIViewController *rootViewController = [UIViewController new]; | ||
| 57 | rootViewController.view = rootView; | ||
| 58 | self.window.rootViewController = rootViewController; | ||
| 59 | [self.window makeKeyAndVisible]; | ||
| 60 | return YES; | ||
| 61 | } | ||
| 62 | |||
| 63 | /// This method controls whether the `concurrentRoot`feature of React18 is turned on or off. | ||
| 64 | /// | ||
| 65 | /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html | ||
| 66 | /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). | ||
| 67 | /// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`. | ||
| 68 | - (BOOL)concurrentRootEnabled | ||
| 69 | { | ||
| 70 | // Switch this bool to turn on and off the concurrent root | ||
| 71 | return true; | ||
| 72 | } | ||
| 73 | |||
| 74 | - (NSDictionary *)prepareInitialProps | ||
| 75 | { | ||
| 76 | NSMutableDictionary *initProps = [NSMutableDictionary new]; | ||
| 77 | |||
| 78 | #ifdef RCT_NEW_ARCH_ENABLED | ||
| 79 | initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]); | ||
| 80 | #endif | 9 | self.moduleName = @"RnDiffApp"; |
| 10 | // You can add your custom initial props in the dictionary below. | ||
| 11 | // They will be passed down to the ViewController used by React Native. | ||
| 12 | self.initialProps = @{}; | ||
| 81 | 13 | ||
| 82 | return initProps; | 14 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; |
| 83 | } | 15 | } |
| 84 | 16 | ||
| 85 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge | 17 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge |
@@ -91,43 +23,14 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot"; | |||
| 91 | #endif | 23 | #endif |
| 92 | } | 24 | } |
| 93 | 25 | ||
| 94 | #if RCT_NEW_ARCH_ENABLED | ||
| 95 | |||
| 96 | #pragma mark - RCTCxxBridgeDelegate | ||
| 97 | |||
| 98 | - (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge | ||
| 99 | { | ||
| 100 | _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge | ||
| 101 | delegate:self | ||
| 102 | jsInvoker:bridge.jsCallInvoker]; | ||
| 103 | return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager); | ||
| 104 | } | ||
| 105 | |||
| 106 | #pragma mark RCTTurboModuleManagerDelegate | ||
| 107 | |||
| 108 | - (Class)getModuleClassFromName:(const char *)name | ||
| 109 | { | ||
| 110 | return RCTCoreModulesClassProvider(name); | ||
| 111 | } | ||
| 112 | |||
| 113 | - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name | ||
| 114 | jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker | ||
| 115 | { | ||
| 116 | return nullptr; | ||
| 117 | } | ||
| 118 | |||
| 119 | - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name | ||
| 120 | initParams: | ||
| 121 | (const facebook::react::ObjCTurboModule::InitParams &)params | ||
| 122 | { | ||
| 123 | return nullptr; | ||
| 124 | } | ||
| 125 | |||
| 126 | - (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass | 26 | /// This method controls whether the `concurrentRoot`feature of React18 is turned on or off. |
| 27 | /// | ||
| 28 | /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html | ||
| 29 | /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). | ||
| 30 | /// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`. | ||
| 31 | - (BOOL)concurrentRootEnabled | ||
| 127 | { | 32 | { |
| 128 | return RCTAppSetupDefaultModuleFromClass(moduleClass); | 33 | return true; |
| 129 | } | 34 | } |
| 130 | 35 | ||
| 131 | #endif | ||
| 132 | |||
| 133 | @end | 36 | @end |
@@ -17,11 +17,11 @@ | |||
| 17 | <key>CFBundlePackageType</key> | 17 | <key>CFBundlePackageType</key> |
| 18 | <string>APPL</string> | 18 | <string>APPL</string> |
| 19 | <key>CFBundleShortVersionString</key> | 19 | <key>CFBundleShortVersionString</key> |
| 20 | <string>1.0</string> | 20 | <string>$(MARKETING_VERSION)</string> |
| 21 | <key>CFBundleSignature</key> | 21 | <key>CFBundleSignature</key> |
| 22 | <string>????</string> | 22 | <string>????</string> |
| 23 | <key>CFBundleVersion</key> | 23 | <key>CFBundleVersion</key> |
| 24 | <string>1</string> | 24 | <string>$(CURRENT_PROJECT_VERSION)</string> |
| 25 | <key>LSRequiresIPhoneOS</key> | 25 | <key>LSRequiresIPhoneOS</key> |
| 26 | <true/> | 26 | <true/> |
| 27 | <key>NSAppTransportSecurity</key> | 27 | <key>NSAppTransportSecurity</key> |
@@ -0,0 +1,3 @@ | |
| 1 | { |
| 2 | "extends": "@tsconfig/react-native/tsconfig.json" |
| 3 | } |