Skip to content

Commit 76aa72f

Browse files
committed
docs(example): update example to rn68
this means arm64 apple is now supported reverted to auto-linking style vs metro-config / hard link style to module source, that is unworkable with regard to maintainence really will move it all to react-native-test-app shortly
1 parent b3b0b38 commit 76aa72f

32 files changed

+3924
-4024
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"semi": true,
66
"singleQuote": true,
77
"bracketSpacing": true,
8-
"jsxBracketSameLine": false,
8+
"bracketSameLine": false,
99
"tabWidth": 2,
1010
"printWidth": 100
1111
}

example/.flowconfig

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,42 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
10-
11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
node_modules/react-native/Libraries/react-native/React.js
15-
168
; Ignore polyfills
179
node_modules/react-native/Libraries/polyfills/.*
1810

19-
; These should not be required directly
20-
; require from fbjs/lib instead: require('fbjs/lib/warning')
21-
node_modules/warning/.*
22-
2311
; Flow doesn't support platforms
24-
.*/Libraries/Utilities/HMRLoadingView.js
12+
.*/Libraries/Utilities/LoadingView.js
2513

2614
[untyped]
2715
.*/node_modules/@react-native-community/cli/.*/.*
2816

2917
[include]
3018

3119
[libs]
32-
node_modules/react-native/Libraries/react-native/react-native-interface.js
20+
node_modules/react-native/interface.js
3321
node_modules/react-native/flow/
3422

3523
[options]
3624
emoji=true
3725

38-
esproposal.optional_chaining=enable
39-
esproposal.nullish_coalescing=enable
26+
exact_by_default=true
27+
28+
format.bracket_spacing=false
4029

4130
module.file_ext=.js
4231
module.file_ext=.json
4332
module.file_ext=.ios.js
4433

45-
module.system=haste
46-
module.system.haste.use_name_reducers=true
47-
# get basename
48-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
49-
# strip .js or .js.flow suffix
50-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
51-
# strip .ios suffix
52-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
53-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
54-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
55-
module.system.haste.paths.blacklist=.*/__tests__/.*
56-
module.system.haste.paths.blacklist=.*/__mocks__/.*
57-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
58-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
59-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
60-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation.js
61-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
62-
6334
munge_underscores=true
6435

65-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
36+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
37+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
6638

6739
suppress_type=$FlowIssue
6840
suppress_type=$FlowFixMe
6941
suppress_type=$FlowFixMeProps
7042
suppress_type=$FlowFixMeState
7143

72-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
73-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
74-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
75-
7644
[lints]
7745
sketchy-null-number=warn
7846
sketchy-null-mixed=warn
@@ -81,10 +49,8 @@ untyped-type-import=warn
8149
nonstrict-import=warn
8250
deprecated-type=warn
8351
unsafe-getters-setters=warn
84-
inexact-spread=warn
8552
unnecessary-invariant=warn
8653
signature-verification-failure=warn
87-
deprecated-utility=error
8854

8955
[strict]
9056
deprecated-type
@@ -96,4 +62,4 @@ untyped-import
9662
untyped-type-import
9763

9864
[version]
99-
^0.100.0
65+
^0.162.0

example/android/app/build.gradle

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import com.android.build.OutputFile
1515
* // the name of the generated asset file containing your JS bundle
1616
* bundleAssetName: "index.android.bundle",
1717
*
18-
* // the entry file for bundle generation
18+
* // the entry file for bundle generation. If none specified and
19+
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
20+
* // default. Can be overridden with ENTRY_FILE environment variable.
1921
* entryFile: "index.android.js",
2022
*
21-
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
23+
* // https://reactnative.dev/docs/performance#enable-the-ram-format
2224
* bundleCommand: "ram-bundle",
2325
*
2426
* // whether to bundle JS and assets in debug mode
@@ -37,7 +39,7 @@ import com.android.build.OutputFile
3739
* // bundleInBeta: true,
3840
*
3941
* // whether to disable dev mode in custom build variants (by default only disabled in release)
40-
* // for AppleAuthExample: to disable dev mode in the staging build type (if configured)
42+
* // for example: to disable dev mode in the staging build type (if configured)
4143
* devDisabledInStaging: true,
4244
* // The configuration property can be in the following formats
4345
* // 'devDisabledIn${productFlavor}${buildType}'
@@ -64,7 +66,7 @@ import com.android.build.OutputFile
6466
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
6567
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
6668
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67-
* // for AppleAuthExample, you might want to remove it from here.
69+
* // for example, you might want to remove it from here.
6870
* inputExcludes: ["android/**", "ios/**"],
6971
*
7072
* // override which node gets called and with what additional arguments
@@ -99,7 +101,7 @@ def enableProguardInReleaseBuilds = false
99101
/**
100102
* The preferred build flavor of JavaScriptCore.
101103
*
102-
* For AppleAuthExample, to use the international variant, you can use:
104+
* For example, to use the international variant, you can use:
103105
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
104106
*
105107
* The international variant includes ICU i18n library and necessary data
@@ -112,19 +114,21 @@ def jscFlavor = 'org.webkit:android-jsc:+'
112114
/**
113115
* Whether to enable the Hermes VM.
114116
*
115-
* 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
116118
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
117119
* and the benefits of using Hermes will therefore be sharply reduced.
118120
*/
119121
def enableHermes = project.ext.react.get("enableHermes", false);
120122

123+
/**
124+
* Architectures to build native code for in debug.
125+
*/
126+
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
127+
121128
android {
122-
compileSdkVersion rootProject.ext.compileSdkVersion
129+
ndkVersion rootProject.ext.ndkVersion
123130

124-
compileOptions {
125-
sourceCompatibility JavaVersion.VERSION_1_8
126-
targetCompatibility JavaVersion.VERSION_1_8
127-
}
131+
compileSdkVersion rootProject.ext.compileSdkVersion
128132

129133
defaultConfig {
130134
applicationId "com.example.reactnativeappleauth"
@@ -152,52 +156,54 @@ android {
152156
buildTypes {
153157
debug {
154158
signingConfig signingConfigs.debug
159+
if (nativeArchitectures) {
160+
ndk {
161+
abiFilters nativeArchitectures.split(',')
162+
}
163+
}
155164
}
156165
release {
157166
// Caution! In production, you need to generate your own keystore file.
158-
// see https://facebook.github.io/react-native/docs/signed-apk-android.
167+
// see https://reactnative.dev/docs/signed-apk-android.
159168
signingConfig signingConfigs.debug
160169
minifyEnabled enableProguardInReleaseBuilds
161170
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
162171
}
163172
}
173+
164174
// applicationVariants are e.g. debug, release
165175
applicationVariants.all { variant ->
166176
variant.outputs.each { output ->
167177
// For each separate APK per architecture, set a unique version code as described here:
168178
// https://developer.android.com/studio/build/configure-apk-splits.html
179+
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
169180
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
170181
def abi = output.getFilter(OutputFile.ABI)
171182
if (abi != null) { // null for the universal-debug, universal-release variants
172183
output.versionCodeOverride =
173-
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
184+
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
174185
}
175186

176187
}
177188
}
178-
179-
packagingOptions {
180-
pickFirst "lib/armeabi-v7a/libc++_shared.so"
181-
pickFirst "lib/arm64-v8a/libc++_shared.so"
182-
pickFirst "lib/x86/libc++_shared.so"
183-
pickFirst "lib/x86_64/libc++_shared.so"
184-
}
185189
}
186190

187191
dependencies {
188192
implementation fileTree(dir: "libs", include: ["*.jar"])
189193
//noinspection GradleDynamicVersion
190194
implementation "com.facebook.react:react-native:+" // From node_modules
191195

192-
193196
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
197+
194198
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
195-
exclude group:'com.facebook.fbjni'
199+
exclude group:'com.facebook.fbjni'
196200
}
201+
197202
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
198203
exclude group:'com.facebook.flipper'
199204
exclude group:'com.squareup.okhttp3', module:'okhttp'
200205
}
206+
201207
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
202208
exclude group:'com.facebook.flipper'
203209
}
@@ -210,14 +216,14 @@ dependencies {
210216
implementation jscFlavor
211217
}
212218

213-
implementation project(':reactnativeappleauth')
219+
// implementation project(':reactnativeappleauth')
214220
}
215221

216222
// Run this once to be able to run the application with BUCK
217223
// puts all compile dependencies into folder libs for BUCK to use
218224
task copyDownloadableDepsToLibs(type: Copy) {
219-
from configurations.compile
225+
from configurations.implementation
220226
into 'libs'
221227
}
222228

223-
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
229+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/android/app/proguard-rules.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
# http://developer.android.com/guide/developing/tools/proguard.html
99

1010
# Add any project specific keep options here:
11+
-keep class com.facebook.hermes.unicode.** { *; }
12+
-keep class com.facebook.jni.** { *; }

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44

55
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
66

7-
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
8-
</manifest>
7+
<application
8+
android:usesCleartextTraffic="true"
9+
tools:targetApi="28"
10+
tools:ignore="GoogleAppIndexingWarning">
11+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
12+
</application>
13+
</manifest>

example/android/app/src/debug/java/com/example/reactnativeappleauth/ReactNativeFlipper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ public class ReactNativeFlipper {
2828
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
2929
if (FlipperUtils.shouldEnableFlipper(context)) {
3030
final FlipperClient client = AndroidFlipperClient.getInstance(context);
31+
3132
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
3233
client.addPlugin(new ReactFlipperPlugin());
3334
client.addPlugin(new DatabasesFlipperPlugin(context));
3435
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
3536
client.addPlugin(CrashReporterPlugin.getInstance());
37+
3638
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
3739
NetworkingModule.setCustomClientBuilder(
3840
new NetworkingModule.CustomClientBuilder() {
@@ -43,6 +45,7 @@ public void apply(OkHttpClient.Builder builder) {
4345
});
4446
client.addPlugin(networkFlipperPlugin);
4547
client.start();
48+
4649
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
4750
// Hence we run if after all native modules have been initialized
4851
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
@@ -66,4 +69,4 @@ public void run() {
6669
}
6770
}
6871
}
69-
}
72+
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@
2121
<category android:name="android.intent.category.LAUNCHER" />
2222
</intent-filter>
2323
</activity>
24-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
2524
</application>
26-
27-
</manifest>
25+
</manifest>

example/android/app/src/main/java/com/example/reactnativeappleauth/MainApplication.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import android.content.Context;
55
import com.facebook.react.PackageList;
66
import com.facebook.react.ReactApplication;
7+
import com.facebook.react.ReactInstanceManager;
78
import com.facebook.react.ReactNativeHost;
89
import com.facebook.react.ReactPackage;
9-
import com.facebook.react.ReactInstanceManager;
1010
import com.facebook.soloader.SoLoader;
1111
import java.lang.reflect.InvocationTargetException;
1212
import java.util.List;
1313

14-
import com.RNAppleAuthentication.AppleAuthenticationAndroidPackage;
14+
// import com.RNAppleAuthentication.AppleAuthenticationAndroidPackage;
1515

1616
public class MainApplication extends Application implements ReactApplication {
1717

@@ -26,9 +26,9 @@ public boolean getUseDeveloperSupport() {
2626
protected List<ReactPackage> getPackages() {
2727
@SuppressWarnings("UnnecessaryLocalVariable")
2828
List<ReactPackage> packages = new PackageList(this).getPackages();
29-
// Packages that cannot be autolinked yet can be added manually here, for AppleAuthExample:
29+
// Packages that cannot be autolinked yet can be added manually here, for example:
3030
// packages.add(new MyReactNativePackage());
31-
packages.add(new AppleAuthenticationAndroidPackage());
31+
// packages.add(new AppleAuthenticationAndroidPackage());
3232

3333
return packages;
3434
}
@@ -48,22 +48,25 @@ public ReactNativeHost getReactNativeHost() {
4848
public void onCreate() {
4949
super.onCreate();
5050
SoLoader.init(this, /* native exopackage */ false);
51-
initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want Flipper enabled
51+
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
5252
}
5353

5454
/**
55-
* Loads Flipper in React Native templates.
55+
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
56+
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
5657
*
5758
* @param context
59+
* @param reactInstanceManager
5860
*/
59-
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
61+
private static void initializeFlipper(
62+
Context context, ReactInstanceManager reactInstanceManager) {
6063
if (BuildConfig.DEBUG) {
6164
try {
6265
/*
6366
We use reflection here to pick up the class that initializes Flipper,
6467
since Flipper library is not available in release mode
6568
*/
66-
Class<?> aClass = Class.forName("com.reactnativeappleauthExample.ReactNativeFlipper");
69+
Class<?> aClass = Class.forName("com.example.reactnativeappleauth.ReactNativeFlipper");
6770
aClass
6871
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
6972
.invoke(null, context, reactInstanceManager);
@@ -78,4 +81,4 @@ private static void initializeFlipper(Context context, ReactInstanceManager reac
7881
}
7982
}
8083
}
81-
}
84+
}

0 commit comments

Comments
 (0)