Skip to content

Commit ae9a6c9

Browse files
authored
chore: update example to RN 0.62.2 (#111)
1 parent f55e7ff commit ae9a6c9

File tree

13 files changed

+873
-941
lines changed

13 files changed

+873
-941
lines changed

.flowconfig

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@ node_modules/warning/.*
1515
; Flow doesn't support platforms
1616
.*/Libraries/Utilities/LoadingView.js
1717

18-
; Ignore example folder
19-
.*/example/.*
20-
21-
2218
[untyped]
2319
.*/node_modules/@react-native-community/cli/.*/.*
2420

2521
[include]
2622

2723
[libs]
28-
node_modules/react-native/Libraries/react-native/react-native-interface.js
24+
node_modules/react-native/interface.js
2925
node_modules/react-native/flow/
3026

3127
[options]
@@ -40,9 +36,8 @@ module.file_ext=.ios.js
4036

4137
munge_underscores=true
4238

43-
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
4439
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
45-
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'
40+
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'
4641

4742
suppress_type=$FlowIssue
4843
suppress_type=$FlowFixMe
@@ -76,4 +71,4 @@ untyped-import
7671
untyped-type-import
7772

7873
[version]
79-
^0.105.0
74+
^0.113.0

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
*.pbxproj -text
2+
# specific for windows script files
3+
*.bat text eol=crlf

example/android/app/build.gradle

Lines changed: 27 additions & 3 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://reactnative.dev/docs/performance#enable-the-ram-format
23+
* // https://facebook.github.io/react-native/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, // clean and rebuild if changing
8182
]
8283

@@ -162,6 +163,14 @@ android {
162163
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
163164
}
164165
}
166+
167+
packagingOptions {
168+
pickFirst "lib/armeabi-v7a/libc++_shared.so"
169+
pickFirst "lib/arm64-v8a/libc++_shared.so"
170+
pickFirst "lib/x86/libc++_shared.so"
171+
pickFirst "lib/x86_64/libc++_shared.so"
172+
}
173+
165174
// applicationVariants are e.g. debug, release
166175
applicationVariants.all { variant ->
167176
variant.outputs.each { output ->
@@ -180,8 +189,23 @@ android {
180189

181190
dependencies {
182191
implementation fileTree(dir: "libs", include: ["*.jar"])
192+
//noinspection GradleDynamicVersion
183193
implementation "com.facebook.react:react-native:+" // From node_modules
184194

195+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
196+
197+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
198+
exclude group:'com.facebook.fbjni'
199+
}
200+
201+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
202+
exclude group:'com.facebook.flipper'
203+
}
204+
205+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
206+
exclude group:'com.facebook.flipper'
207+
}
208+
185209
if (enableHermes) {
186210
def hermesPath = "../../node_modules/hermes-engine/android/";
187211
debugImplementation files(hermesPath + "hermes-debug.aar")

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<activity
1414
android:name=".MainActivity"
1515
android:label="@string/app_name"
16-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
16+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
17+
android:launchMode="singleTask"
1718
android:windowSoftInputMode="adjustResize">
1819
<intent-filter>
1920
<action android:name="android.intent.action.MAIN" />
@@ -23,4 +24,4 @@
2324
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
2425
</application>
2526

26-
</manifest>
27+
</manifest>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 com.example;
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+
32+
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33+
client.addPlugin(new ReactFlipperPlugin());
34+
client.addPlugin(new DatabasesFlipperPlugin(context));
35+
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36+
client.addPlugin(CrashReporterPlugin.getInstance());
37+
38+
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39+
NetworkingModule.setCustomClientBuilder(
40+
new NetworkingModule.CustomClientBuilder() {
41+
@Override
42+
public void apply(OkHttpClient.Builder builder) {
43+
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44+
}
45+
});
46+
client.addPlugin(networkFlipperPlugin);
47+
client.start();
48+
49+
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
50+
// Hence we run if after all native modules have been initialized
51+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
52+
if (reactContext == null) {
53+
reactInstanceManager.addReactInstanceEventListener(
54+
new ReactInstanceManager.ReactInstanceEventListener() {
55+
@Override
56+
public void onReactContextInitialized(ReactContext reactContext) {
57+
reactInstanceManager.removeReactInstanceEventListener(this);
58+
reactContext.runOnNativeModulesQueueThread(
59+
new Runnable() {
60+
@Override
61+
public void run() {
62+
client.addPlugin(new FrescoFlipperPlugin());
63+
}
64+
});
65+
}
66+
});
67+
} else {
68+
client.addPlugin(new FrescoFlipperPlugin());
69+
}
70+
}
71+
}
72+
}

example/android/gradle.properties

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1-
# Project-wide Gradle settings.
2-
3-
# IDE (e.g. Android Studio) users:
4-
# Gradle settings configured through the IDE *will override*
5-
# any settings specified in this file.
6-
7-
# For more details on how to configure your build environment visit
8-
# http://www.gradle.org/docs/current/userguide/build_environment.html
9-
10-
# Specifies the JVM arguments used for the daemon process.
11-
# The setting is particularly useful for tweaking memory settings.
12-
# Default value: -Xmx10248m -XX:MaxPermSize=256m
13-
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14-
15-
# When configured, Gradle will run in incubating parallel mode.
16-
# This option should only be used with decoupled projects. More details, visit
171
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
182
# org.gradle.parallel=true
19-
3+
# AndroidX package structure to make it clearer which packages are bundled with the
4+
# Android operating system, and which are packaged with your app's APK
5+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
206
android.useAndroidX=true
7+
# Automatically convert third-party libraries to use AndroidX
218
android.enableJetifier=true
9+
# Version of flipper SDK to use with React Native
10+
FLIPPER_VERSION=0.33.1

example/android/gradlew

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# you may not use this file except in compliance with the License.
88
# You may obtain a copy of the License at
99
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
10+
# https://www.apache.org/licenses/LICENSE-2.0
1111
#
1212
# Unless required by applicable law or agreed to in writing, software
1313
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -125,8 +125,8 @@ if $darwin; then
125125
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126126
fi
127127

128-
# For Cygwin, switch paths to Windows format before running java
129-
if $cygwin ; then
128+
# For Cygwin or MSYS, switch paths to Windows format before running java
129+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130130
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131131
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132132
JAVACMD=`cygpath --unix "$JAVACMD"`

example/ios/Podfile

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@ platform :ios, '9.0'
22
$node_modules_path = '../../node_modules'
33
require_relative "#{$node_modules_path}/@react-native-community/cli-platform-ios/native_modules"
44

5+
def add_flipper_pods!(versions = {})
6+
versions['Flipper'] ||= '~> 0.33.1'
7+
versions['DoubleConversion'] ||= '1.1.7'
8+
versions['Flipper-Folly'] ||= '~> 2.1'
9+
versions['Flipper-Glog'] ||= '0.3.6'
10+
versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
11+
versions['Flipper-RSocket'] ||= '~> 1.0'
12+
13+
pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug'
14+
pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug'
15+
pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
16+
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configuration => 'Debug'
17+
pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configuration => 'Debug'
18+
19+
# List all transitive dependencies for FlipperKit pods
20+
# to avoid them being linked in Release builds
21+
pod 'Flipper', versions['Flipper'], :configuration => 'Debug'
22+
pod 'Flipper-DoubleConversion', versions['DoubleConversion'], :configuration => 'Debug'
23+
pod 'Flipper-Folly', versions['Flipper-Folly'], :configuration => 'Debug'
24+
pod 'Flipper-Glog', versions['Flipper-Glog'], :configuration => 'Debug'
25+
pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configuration => 'Debug'
26+
pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configuration => 'Debug'
27+
pod 'FlipperKit/Core', versions['Flipper'], :configuration => 'Debug'
28+
pod 'FlipperKit/CppBridge', versions['Flipper'], :configuration => 'Debug'
29+
pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configuration => 'Debug'
30+
pod 'FlipperKit/FBDefines', versions['Flipper'], :configuration => 'Debug'
31+
pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configuration => 'Debug'
32+
pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configuration => 'Debug'
33+
pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configuration => 'Debug'
34+
pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
35+
end
36+
37+
# Post Install processing for Flipper
38+
def flipper_post_install(installer)
39+
installer.pods_project.targets.each do |target|
40+
if target.name == 'YogaKit'
41+
target.build_configurations.each do |config|
42+
config.build_settings['SWIFT_VERSION'] = '4.1'
43+
end
44+
end
45+
end
46+
end
47+
548
target 'example' do
649
# Pods for example
750
pod 'FBLazyVector', :path => "#{$node_modules_path}/react-native/Libraries/FBLazyVector"
@@ -27,21 +70,30 @@ target 'example' do
2770
pod 'React-jsi', :path => "#{$node_modules_path}/react-native/ReactCommon/jsi"
2871
pod 'React-jsiexecutor', :path => "#{$node_modules_path}/react-native/ReactCommon/jsiexecutor"
2972
pod 'React-jsinspector', :path => "#{$node_modules_path}/react-native/ReactCommon/jsinspector"
30-
pod 'ReactCommon/jscallinvoker', :path => "#{$node_modules_path}/react-native/ReactCommon"
73+
pod 'ReactCommon/callinvoker', :path => "#{$node_modules_path}/react-native/ReactCommon"
3174
pod 'ReactCommon/turbomodule/core', :path => "#{$node_modules_path}/react-native/ReactCommon"
32-
pod 'Yoga', :path => "#{$node_modules_path}/react-native/ReactCommon/yoga"
75+
pod 'Yoga', :path => "#{$node_modules_path}/react-native/ReactCommon/yoga", :modular_headers => true
3376

3477
pod 'DoubleConversion', :podspec => "#{$node_modules_path}/react-native/third-party-podspecs/DoubleConversion.podspec"
3578
pod 'glog', :podspec => "#{$node_modules_path}/react-native/third-party-podspecs/glog.podspec"
3679
pod 'Folly', :podspec => "#{$node_modules_path}/react-native/third-party-podspecs/Folly.podspec"
3780
pod 'RNCPushNotificationIOS', :path => "../../"
3881

3982
target 'exampleTests' do
40-
inherit! :search_paths
83+
inherit! :complete
4184
# Pods for testing
4285
end
4386

4487
use_native_modules!
88+
89+
# Enables Flipper.
90+
#
91+
# Note that if you have use_frameworks! enabled, Flipper will not work and
92+
# you should disable these next few lines.
93+
add_flipper_pods!
94+
post_install do |installer|
95+
flipper_post_install(installer)
96+
end
4597
end
4698

4799
target 'example-tvOS' do
@@ -51,5 +103,4 @@ target 'example-tvOS' do
51103
inherit! :search_paths
52104
# Pods for testing
53105
end
54-
55-
end
106+
end

0 commit comments

Comments
 (0)