From 7657a7eecdb4020e615b231015af300a42ee2163 Mon Sep 17 00:00:00 2001 From: "tim.lin" Date: Fri, 18 Oct 2024 14:56:39 +0800 Subject: [PATCH 1/2] Remove flipper on Android --- dev-app/android/app/build.gradle | 6 -- .../ReactNativeFlipper.java | 68 ------------------- .../MainApplication.java | 1 - .../ReactNativeFlipper.java | 12 ---- dev-app/android/gradle.properties | 1 - 5 files changed, 88 deletions(-) delete mode 100644 dev-app/android/app/src/debug/java/com/dev/app/stripeterminalreactnative/ReactNativeFlipper.java delete mode 100644 dev-app/android/app/src/release/java/com/dev/app/stripeterminalreactnative/ReactNativeFlipper.java diff --git a/dev-app/android/app/build.gradle b/dev-app/android/app/build.gradle index 5d65b405..de6f52ad 100644 --- a/dev-app/android/app/build.gradle +++ b/dev-app/android/app/build.gradle @@ -70,12 +70,6 @@ dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") - debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { - exclude group:'com.squareup.okhttp3', module:'okhttp' - } - - debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { diff --git a/dev-app/android/app/src/debug/java/com/dev/app/stripeterminalreactnative/ReactNativeFlipper.java b/dev-app/android/app/src/debug/java/com/dev/app/stripeterminalreactnative/ReactNativeFlipper.java deleted file mode 100644 index 3019273a..00000000 --- a/dev-app/android/app/src/debug/java/com/dev/app/stripeterminalreactnative/ReactNativeFlipper.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - *

This source code is licensed under the MIT license found in the LICENSE file in the root - * directory of this source tree. - */ -package com.dev.app.stripeterminalreactnative; - -import android.content.Context; -import com.facebook.flipper.android.AndroidFlipperClient; -import com.facebook.flipper.android.utils.FlipperUtils; -import com.facebook.flipper.core.FlipperClient; -import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; -import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; -import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; -import com.facebook.flipper.plugins.inspector.DescriptorMapping; -import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; -import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; -import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; -import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; -import com.facebook.react.ReactInstanceEventListener; -import com.facebook.react.ReactInstanceManager; -import com.facebook.react.bridge.ReactContext; -import com.facebook.react.modules.network.NetworkingModule; -import okhttp3.OkHttpClient; - -public class ReactNativeFlipper { - public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { - if (FlipperUtils.shouldEnableFlipper(context)) { - final FlipperClient client = AndroidFlipperClient.getInstance(context); - client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); - client.addPlugin(new DatabasesFlipperPlugin(context)); - client.addPlugin(new SharedPreferencesFlipperPlugin(context)); - client.addPlugin(CrashReporterPlugin.getInstance()); - NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); - NetworkingModule.setCustomClientBuilder( - new NetworkingModule.CustomClientBuilder() { - @Override - public void apply(OkHttpClient.Builder builder) { - builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); - } - }); - client.addPlugin(networkFlipperPlugin); - client.start(); - // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized - // Hence we run if after all native modules have been initialized - ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); - if (reactContext == null) { - reactInstanceManager.addReactInstanceEventListener( - new ReactInstanceEventListener() { - @Override - public void onReactContextInitialized(ReactContext reactContext) { - reactInstanceManager.removeReactInstanceEventListener(this); - reactContext.runOnNativeModulesQueueThread( - new Runnable() { - @Override - public void run() { - client.addPlugin(new FrescoFlipperPlugin()); - } - }); - } - }); - } else { - client.addPlugin(new FrescoFlipperPlugin()); - } - } - } -} diff --git a/dev-app/android/app/src/main/java/com/dev/app/stripeterminalreactnative/MainApplication.java b/dev-app/android/app/src/main/java/com/dev/app/stripeterminalreactnative/MainApplication.java index 773e654a..34d9e9d6 100644 --- a/dev-app/android/app/src/main/java/com/dev/app/stripeterminalreactnative/MainApplication.java +++ b/dev-app/android/app/src/main/java/com/dev/app/stripeterminalreactnative/MainApplication.java @@ -61,6 +61,5 @@ public void onCreate() { // If you opted-in for the New Architecture, we load the native entry point for this app. DefaultNewArchitectureEntryPoint.load(); } - ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } } diff --git a/dev-app/android/app/src/release/java/com/dev/app/stripeterminalreactnative/ReactNativeFlipper.java b/dev-app/android/app/src/release/java/com/dev/app/stripeterminalreactnative/ReactNativeFlipper.java deleted file mode 100644 index 0a88e875..00000000 --- a/dev-app/android/app/src/release/java/com/dev/app/stripeterminalreactnative/ReactNativeFlipper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.dev.app.stripeterminalreactnative; -import android.content.Context; -import com.facebook.react.ReactInstanceManager; -/** - * Class responsible of loading Flipper inside your React Native application. This is the release - * flavor of it so it's empty as we don't want to load Flipper. - */ -public class ReactNativeFlipper { - public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { - // Do nothing as we don't want to initialize Flipper on Release. - } -} diff --git a/dev-app/android/gradle.properties b/dev-app/android/gradle.properties index d5fb3f7d..9051ad80 100644 --- a/dev-app/android/gradle.properties +++ b/dev-app/android/gradle.properties @@ -20,7 +20,6 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m android.useAndroidX=true android.enableJetifier=false android.defaults.buildfeatures.buildconfig=true -FLIPPER_VERSION=0.182.0 # Use this property to specify which architecture you want to build. # You can also override it from the CLI using # ./gradlew -PreactNativeArchitectures=x86_64 From c53822de2292903ae760837f3de43a5d33cf51f1 Mon Sep 17 00:00:00 2001 From: "tim.lin" Date: Tue, 22 Oct 2024 10:35:59 +0800 Subject: [PATCH 2/2] Remove flipper on iOS --- dev-app/ios/Podfile | 20 ++------------------ dev-app/ios/Podfile.lock | 2 +- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/dev-app/ios/Podfile b/dev-app/ios/Podfile index bb45312a..5959e092 100644 --- a/dev-app/ios/Podfile +++ b/dev-app/ios/Podfile @@ -6,16 +6,7 @@ require Pod::Executable.execute_command('node', ['-p', )', __dir__]).strip platform :ios, '13.0' prepare_react_native_project! -# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. -# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded -# -# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` -# ```js -# module.exports = { -# dependencies: { -# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), -# ``` -flipper_config = FlipperConfiguration.disabled + linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green @@ -29,14 +20,7 @@ target 'StripeTerminalReactNativeDevApp' do use_react_native!( :path => config[:reactNativePath], - # Hermes is now enabled by default. Disable by setting this flag to false. - :hermes_enabled => flags[:hermes_enabled], - :fabric_enabled => flags[:fabric_enabled], - # Enables Flipper. - # - # Note that if you have use_frameworks! enabled, Flipper will not work and - # you should disable the next line. - :flipper_configuration => flipper_config, + # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) diff --git a/dev-app/ios/Podfile.lock b/dev-app/ios/Podfile.lock index aba0b224..9e7be1b3 100644 --- a/dev-app/ios/Podfile.lock +++ b/dev-app/ios/Podfile.lock @@ -648,6 +648,6 @@ SPEC CHECKSUMS: StripeTerminal: f7f5e176979224ed76edb3724f41138fbb28053c Yoga: 4c3aa327e4a6a23eeacd71f61c81df1bcdf677d5 -PODFILE CHECKSUM: e42df060dac549df682e535ef903a0f36c3e799c +PODFILE CHECKSUM: 84a933b80c432feb3d308e0c6d203b2fdba5fa02 COCOAPODS: 1.15.2