Skip to content

Commit ff1f811

Browse files
authored
[test] Update example app to Expo 39 and react-native 0.63.3 (IjzerenHein#122)
* update ios instruction * Update pods version * update example to Expo 39.0.0 & react-native 0.63.3 * fix swift env * fix android build
1 parent be3ae81 commit ff1f811

20 files changed

Lines changed: 2645 additions & 1459 deletions

File tree

‎example/.gitignore‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
node_modules/**/*
2-
.expo/*
3-
npm-debug.*
4-
*.jks
5-
*.p8
6-
*.p12
7-
*.key
8-
*.mobileprovision
9-
*.orig.*
10-
web-build/
11-
web-report/
12-
13-
# macOS
14-
.DS_Store
15-
16-
# The following contents were automatically generated by expo-cli during eject
17-
# ----------------------------------------------------------------------------
18-
191
# OSX
202
#
213
.DS_Store
@@ -58,6 +40,7 @@ yarn-error.log
5840
buck-out/
5941
\.buckd/
6042
*.keystore
43+
!debug.keystore
6144

6245
# fastlane
6346
#
@@ -72,11 +55,10 @@ buck-out/
7255

7356
# Bundle artifacts
7457
*.jsbundle
75-
app.bundle
76-
app.manifest
7758

7859
# CocoaPods
79-
/ios/Pods
60+
/ios/Pods/
8061

8162
# Expo
8263
.expo/*
64+
web-build/

‎example/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ expo start
88

99
## Run natively on iOS
1010

11+
> Make sure the pods are installed:
12+
13+
```sh
14+
cd ios
15+
pod install
16+
```
17+
1118
```sh
1219
yarn ios
1320
```

‎example/android/app/build.gradle‎

Lines changed: 18 additions & 4 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
@@ -76,7 +78,6 @@ import com.android.build.OutputFile
7678
*/
7779

7880
project.ext.react = [
79-
entryFile: "index.js",
8081
enableHermes: false
8182
]
8283

@@ -158,12 +159,13 @@ android {
158159
}
159160
release {
160161
// Caution! In production, you need to generate your own keystore file.
161-
// see https://facebook.github.io/react-native/docs/signed-apk-android.
162+
// see https://reactnative.dev/docs/signed-apk-android.
162163
signingConfig signingConfigs.debug
163164
minifyEnabled enableProguardInReleaseBuilds
164165
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
165166
}
166167
}
168+
167169
// applicationVariants are e.g. debug, release
168170
applicationVariants.all { variant ->
169171
variant.outputs.each { output ->
@@ -182,7 +184,19 @@ android {
182184

183185
dependencies {
184186
implementation fileTree(dir: "libs", include: ["*.jar"])
187+
//noinspection GradleDynamicVersion
185188
implementation "com.facebook.react:react-native:+" // From node_modules
189+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
190+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
191+
exclude group:'com.facebook.fbjni'
192+
}
193+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
194+
exclude group:'com.facebook.flipper'
195+
exclude group:'com.squareup.okhttp3', module:'okhttp'
196+
}
197+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
198+
exclude group:'com.facebook.flipper'
199+
}
186200
addUnimodulesDependencies()
187201

188202
if (enableHermes) {

‎example/android/app/debug.keystore‎

2.2 KB
Binary file not shown.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its 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 nl.ijzerenhein.navigationsharedelementexample;
8+
9+
import android.content.Context;
10+
import com.facebook.flipper.android.AndroidFlipperClient;
11+
import com.facebook.flipper.android.utils.FlipperUtils;
12+
import com.facebook.flipper.core.FlipperClient;
13+
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14+
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15+
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16+
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17+
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18+
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19+
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20+
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21+
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22+
import com.facebook.react.ReactInstanceManager;
23+
import com.facebook.react.bridge.ReactContext;
24+
import com.facebook.react.modules.network.NetworkingModule;
25+
import okhttp3.OkHttpClient;
26+
27+
public class ReactNativeFlipper {
28+
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29+
if (FlipperUtils.shouldEnableFlipper(context)) {
30+
final FlipperClient client = AndroidFlipperClient.getInstance(context);
31+
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
32+
client.addPlugin(new ReactFlipperPlugin());
33+
client.addPlugin(new DatabasesFlipperPlugin(context));
34+
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
35+
client.addPlugin(CrashReporterPlugin.getInstance());
36+
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
37+
NetworkingModule.setCustomClientBuilder(
38+
new NetworkingModule.CustomClientBuilder() {
39+
@Override
40+
public void apply(OkHttpClient.Builder builder) {
41+
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
42+
}
43+
});
44+
client.addPlugin(networkFlipperPlugin);
45+
client.start();
46+
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
47+
// Hence we run if after all native modules have been initialized
48+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
49+
if (reactContext == null) {
50+
reactInstanceManager.addReactInstanceEventListener(
51+
new ReactInstanceManager.ReactInstanceEventListener() {
52+
@Override
53+
public void onReactContextInitialized(ReactContext reactContext) {
54+
reactInstanceManager.removeReactInstanceEventListener(this);
55+
reactContext.runOnNativeModulesQueueThread(
56+
new Runnable() {
57+
@Override
58+
public void run() {
59+
client.addPlugin(new FrescoFlipperPlugin());
60+
}
61+
});
62+
}
63+
});
64+
} else {
65+
client.addPlugin(new FrescoFlipperPlugin());
66+
}
67+
}
68+
}
69+
}

‎example/android/app/src/main/java/nl/ijzerenhein/navigationsharedelementexample/MainActivity.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.facebook.react.ReactRootView;
88
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
99

10-
import expo.modules.splashscreen.SplashScreen;
10+
import expo.modules.splashscreen.singletons.SplashScreen;
1111
import expo.modules.splashscreen.SplashScreenImageResizeMode;
1212

1313
public class MainActivity extends ReactActivity {
@@ -16,7 +16,7 @@ protected void onCreate(Bundle savedInstanceState) {
1616
super.onCreate(savedInstanceState);
1717
// SplashScreen.show(...) has to be called after super.onCreate(...)
1818
// Below line is handled by '@expo/configure-splash-screen' command and it's discouraged to modify it manually
19-
SplashScreen.show(this, SplashScreenImageResizeMode.CONTAIN, ReactRootView.class);
19+
SplashScreen.show(this, SplashScreenImageResizeMode.CONTAIN, ReactRootView.class, false);
2020
}
2121

2222

‎example/android/app/src/main/java/nl/ijzerenhein/navigationsharedelementexample/MainApplication.java‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package nl.ijzerenhein.navigationsharedelementexample;
22

33
import android.app.Application;
4+
import android.content.Context;
45
import android.net.Uri;
56

67
import com.facebook.react.PackageList;
78
import com.facebook.react.ReactApplication;
9+
import com.facebook.react.ReactInstanceManager;
810
import com.facebook.react.ReactNativeHost;
911
import com.facebook.react.ReactPackage;
1012
import com.facebook.react.shell.MainReactPackage;
@@ -21,6 +23,7 @@
2123
import expo.modules.filesystem.FileSystemPackage;
2224
import expo.modules.updates.UpdatesController;
2325

26+
import java.lang.reflect.InvocationTargetException;
2427
import java.util.Arrays;
2528
import java.util.List;
2629
import javax.annotation.Nullable;
@@ -80,5 +83,38 @@ public void onCreate() {
8083
if (!BuildConfig.DEBUG) {
8184
UpdatesController.initialize(this);
8285
}
86+
87+
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
88+
}
89+
90+
/**
91+
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
92+
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
93+
*
94+
* @param context
95+
* @param reactInstanceManager
96+
*/
97+
private static void initializeFlipper(
98+
Context context, ReactInstanceManager reactInstanceManager) {
99+
if (BuildConfig.DEBUG) {
100+
try {
101+
/*
102+
We use reflection here to pick up the class that initializes Flipper,
103+
since Flipper library is not available in release mode
104+
*/
105+
Class<?> aClass = Class.forName("com.39eject.ReactNativeFlipper");
106+
aClass
107+
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
108+
.invoke(null, context, reactInstanceManager);
109+
} catch (ClassNotFoundException e) {
110+
e.printStackTrace();
111+
} catch (NoSuchMethodException e) {
112+
e.printStackTrace();
113+
} catch (IllegalAccessException e) {
114+
e.printStackTrace();
115+
} catch (InvocationTargetException e) {
116+
e.printStackTrace();
117+
}
118+
}
83119
}
84120
}

‎example/android/app/src/main/java/nl/ijzerenhein/navigationsharedelementexample/generated/BasePackageList.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public List<Package> getPackageList() {
1818
new expo.modules.permissions.PermissionsPackage(),
1919
new expo.modules.splashscreen.SplashScreenPackage(),
2020
new expo.modules.sqlite.SQLitePackage(),
21-
new expo.modules.updates.UpdatesPackage(),
22-
new expo.modules.webbrowser.WebBrowserPackage()
21+
new expo.modules.updates.UpdatesPackage()
2322
);
2423
}
2524
}

‎example/android/build.gradle‎

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

33
buildscript {
44
ext {
5-
buildToolsVersion = "28.0.3"
5+
buildToolsVersion = "29.0.2"
66
minSdkVersion = 21
7-
compileSdkVersion = 28
8-
targetSdkVersion = 28
7+
compileSdkVersion = 29
8+
targetSdkVersion = 29
99
}
1010
repositories {
1111
google()
@@ -33,6 +33,6 @@ allprojects {
3333

3434
google()
3535
jcenter()
36-
maven { url 'https://jitpack.io' }
36+
maven { url 'https://www.jitpack.io' }
3737
}
3838
}

‎example/android/gradle.properties‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,13 @@
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1818
# org.gradle.parallel=true
1919

20+
# AndroidX package structure to make it clearer which packages are bundled with the
21+
# Android operating system, and which are packaged with your app's APK
22+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
2023
android.useAndroidX=true
24+
25+
# Automatically convert third-party libraries to use AndroidX
2126
android.enableJetifier=true
27+
28+
# Version of flipper SDK to use with React Native
29+
FLIPPER_VERSION=0.54.0

0 commit comments

Comments
 (0)