Skip to content

Commit adeaed5

Browse files
committed
Update project example to RN 0.69.0
1 parent 37d732e commit adeaed5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+5599
-3658
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ body:
3535
attributes:
3636
label: Library version
3737
description: What version of the library are you using?
38-
placeholder: "x.x.x"
38+
placeholder: 'x.x.x'
3939
validations:
4040
required: true
4141
- type: textarea

.gitignore

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23+
ios/.xcode.env.local
2324

2425
# Android/IntelliJ
2526
#
@@ -30,10 +31,6 @@ local.properties
3031
*.iml
3132
*.hprof
3233

33-
# Visual Studio Code
34-
#
35-
.vscode/
36-
3734
# node.js
3835
#
3936
node_modules/
@@ -53,15 +50,17 @@ buck-out/
5350
# For more information about the recommended setup visit:
5451
# https://docs.fastlane.tools/best-practices/source-control/
5552

56-
*/fastlane/report.xml
57-
*/fastlane/Preview.html
58-
*/fastlane/screenshots
53+
**/fastlane/report.xml
54+
**/fastlane/Preview.html
55+
**/fastlane/screenshots
56+
**/fastlane/test_output
5957

6058
# Bundle artifact
6159
*.jsbundle
6260

63-
# CocoaPods
64-
Pods/
65-
6661
# Bob
6762
dist/
63+
64+
# Ruby / CocoaPods
65+
example/ios/Pods/
66+
example/vendor/bundle/

.prettierignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
node_modules
21
dist/
3-
example/android/app/build
4-
example/ios/Pods
2+
node_modules/
3+
Pods/
4+
5+
example/android/app/build/
6+
example/ios/build/

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ A unified permissions API for React Native on iOS, Android and Windows.<br>
1111
[![Platform - iOS](https://img.shields.io/badge/platform-iOS-000.svg?style=flat&logo=apple)](https://developer.apple.com/ios)
1212
[![Platform - Windows](https://img.shields.io/badge/platform-Windows-0067b8.svg?style=flat&logo=windows)](https://www.microsoft.com/en-us/windows)
1313

14-
1514
## Funding
1615

1716
<a href="https://github.com/sponsors/zoontek">

example/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

example/.gitattributes

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.5

example/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby '2.7.5'
5+
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.2'

example/android/app/build.gradle

Lines changed: 110 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.android.build.OutputFile
2020
* // default. Can be overridden with ENTRY_FILE environment variable.
2121
* entryFile: "index.android.js",
2222
*
23-
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
23+
* // https://reactnative.dev/docs/performance#enable-the-ram-format
2424
* bundleCommand: "ram-bundle",
2525
*
2626
* // whether to bundle JS and assets in debug mode
@@ -114,16 +114,19 @@ def jscFlavor = 'org.webkit:android-jsc:+'
114114
/**
115115
* Whether to enable the Hermes VM.
116116
*
117-
* This should be set on project.ext.react and mirrored here. If it is not set
117+
* This should be set on project.ext.react and that value will be read here. If it is not set
118118
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
119119
* and the benefits of using Hermes will therefore be sharply reduced.
120120
*/
121121
def enableHermes = project.ext.react.get("enableHermes", false);
122122

123123
/**
124-
* Architectures to build native code for in debug.
124+
* Architectures to build native code for.
125125
*/
126-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
126+
def reactNativeArchitectures() {
127+
def value = project.getProperties().get("reactNativeArchitectures")
128+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
129+
}
127130

128131
android {
129132
ndkVersion rootProject.ext.ndkVersion
@@ -136,13 +139,82 @@ android {
136139
targetSdkVersion rootProject.ext.targetSdkVersion
137140
versionCode 1
138141
versionName "1.0"
142+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
143+
144+
if (isNewArchitectureEnabled()) {
145+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
146+
externalNativeBuild {
147+
ndkBuild {
148+
arguments "APP_PLATFORM=android-21",
149+
"APP_STL=c++_shared",
150+
"NDK_TOOLCHAIN_VERSION=clang",
151+
"GENERATED_SRC_DIR=$buildDir/generated/source",
152+
"PROJECT_BUILD_DIR=$buildDir",
153+
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
154+
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
155+
"NODE_MODULES_DIR=$rootDir/../node_modules"
156+
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
157+
cppFlags "-std=c++17"
158+
// Make sure this target name is the same you specify inside the
159+
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
160+
targets "rnpermissionsexample_appmodules"
161+
}
162+
}
163+
if (!enableSeparateBuildPerCPUArchitecture) {
164+
ndk {
165+
abiFilters (*reactNativeArchitectures())
166+
}
167+
}
168+
}
139169
}
170+
171+
if (isNewArchitectureEnabled()) {
172+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
173+
externalNativeBuild {
174+
ndkBuild {
175+
path "$projectDir/src/main/jni/Android.mk"
176+
}
177+
}
178+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
179+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
180+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
181+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
182+
into("$buildDir/react-ndk/exported")
183+
}
184+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
185+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
186+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
187+
into("$buildDir/react-ndk/exported")
188+
}
189+
afterEvaluate {
190+
// If you wish to add a custom TurboModule or component locally,
191+
// you should uncomment this line.
192+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
193+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
194+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
195+
196+
// Due to a bug inside AGP, we have to explicitly set a dependency
197+
// between configureNdkBuild* tasks and the preBuild tasks.
198+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
199+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
200+
configureNdkBuildDebug.dependsOn(preDebugBuild)
201+
reactNativeArchitectures().each { architecture ->
202+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
203+
dependsOn("preDebugBuild")
204+
}
205+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
206+
dependsOn("preReleaseBuild")
207+
}
208+
}
209+
}
210+
}
211+
140212
splits {
141213
abi {
142214
reset()
143215
enable enableSeparateBuildPerCPUArchitecture
144216
universalApk false // If true, also generate a universal APK
145-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
217+
include (*reactNativeArchitectures())
146218
}
147219
}
148220
signingConfigs {
@@ -156,28 +228,16 @@ android {
156228
buildTypes {
157229
debug {
158230
signingConfig signingConfigs.debug
159-
if (nativeArchitectures) {
160-
ndk {
161-
abiFilters nativeArchitectures.split(',')
162-
}
163-
}
164231
}
165232
release {
166233
// Caution! In production, you need to generate your own keystore file.
167-
// see https://facebook.github.io/react-native/docs/signed-apk-android.
234+
// see https://reactnative.dev/docs/signed-apk-android.
168235
signingConfig signingConfigs.debug
169236
minifyEnabled enableProguardInReleaseBuilds
170237
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
171238
}
172239
}
173240

174-
packagingOptions {
175-
pickFirst "lib/armeabi-v7a/libc++_shared.so"
176-
pickFirst "lib/arm64-v8a/libc++_shared.so"
177-
pickFirst "lib/x86/libc++_shared.so"
178-
pickFirst "lib/x86_64/libc++_shared.so"
179-
}
180-
181241
// applicationVariants are e.g. debug, release
182242
applicationVariants.all { variant ->
183243
variant.outputs.each { output ->
@@ -197,32 +257,51 @@ android {
197257

198258
dependencies {
199259
implementation fileTree(dir: "libs", include: ["*.jar"])
260+
200261
//noinspection GradleDynamicVersion
201-
implementation "com.facebook.react:react-native:+" // From node_modules
262+
implementation "com.facebook.react:react-native:+" // From node_modules
202263

203-
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
264+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
204265

205266
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
206267
exclude group:'com.facebook.fbjni'
207268
}
208269

209270
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
210271
exclude group:'com.facebook.flipper'
272+
exclude group:'com.squareup.okhttp3', module:'okhttp'
211273
}
212274

213275
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
214276
exclude group:'com.facebook.flipper'
215277
}
216278

217279
if (enableHermes) {
218-
def hermesPath = "../../node_modules/hermes-engine/android/";
219-
debugImplementation files(hermesPath + "hermes-debug.aar")
220-
releaseImplementation files(hermesPath + "hermes-release.aar")
280+
//noinspection GradleDynamicVersion
281+
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
282+
exclude group:'com.facebook.fbjni'
283+
}
221284
} else {
222285
implementation jscFlavor
223286
}
224287
}
225288

289+
if (isNewArchitectureEnabled()) {
290+
// If new architecture is enabled, we let you build RN from source
291+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
292+
// This will be applied to all the imported transtitive dependency.
293+
configurations.all {
294+
resolutionStrategy.dependencySubstitution {
295+
substitute(module("com.facebook.react:react-native"))
296+
.using(project(":ReactAndroid"))
297+
.because("On New Architecture we're building React Native from source")
298+
substitute(module("com.facebook.react:hermes-engine"))
299+
.using(project(":ReactAndroid:hermes-engine"))
300+
.because("On New Architecture we're building Hermes from source")
301+
}
302+
}
303+
}
304+
226305
// Run this once to be able to run the application with BUCK
227306
// puts all compile dependencies into folder libs for BUCK to use
228307
task copyDownloadableDepsToLibs(type: Copy) {
@@ -231,3 +310,11 @@ task copyDownloadableDepsToLibs(type: Copy) {
231310
}
232311

233312
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
313+
314+
def isNewArchitectureEnabled() {
315+
// To opt-in for the New Architecture, you can either:
316+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
317+
// - Invoke gradle with `-newArchEnabled=true`
318+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
319+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
320+
}

example/android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
android:usesCleartextTraffic="true"
99
tools:targetApi="28"
1010
tools:ignore="GoogleAppIndexingWarning">
11-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
11+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
1212
</application>
1313
</manifest>

0 commit comments

Comments
 (0)