sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

IOS crash on the release build

Open usmanbajwa878 opened this issue 1 year ago • 1 comments

What React Native libraries do you use?

React Navigation

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

5.32.0

How does your development environment look like?

OS: macOS 14.3.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 1.90 GB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.20.4 path: ~/.nvm/versions/node/v18.20.4/bin/node Yarn: version: 3.2.1 path: ~/Documents/projects/mispay-mobile-app/node_modules/.bin/yarn npm: version: 10.7.0 path: ~/.nvm/versions/node/v18.20.4/bin/npm Watchman: version: 2024.08.26.00 path: /usr/local/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /Users/usmanbajwa/.rvm/gems/ruby-2.7.8/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 23.2 - iOS 17.2 - macOS 14.2 - tvOS 17.2 - visionOS 1.0 - watchOS 10.2 Android SDK: Not Found IDEs: Android Studio: 2023.1 AI-231.9392.1.2311.11330709 Xcode: version: 15.2/15C500b path: /usr/bin/xcodebuild Languages: Java: version: 17.0.12 path: /usr/bin/javac Ruby: version: 2.7.8 path: /Users/usmanbajwa/.rvm/rubies/ruby-2.7.8/bin/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.6 wanted: 0.72.6 react-native-macos: Not Found npmGlobalPackages: "react-native": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: false newArchEnabled: false

Sentry.init()

Sentry.init({ dsn: '', debug: false, environment: ENV_URL, enableAppHangTracking: true, autoInitializeNativeSdk: false, tracesSampleRate: 0.2, beforeSend(event, hint) { console.log('beforeSend', event, hint) event.exception?.values?.reverse() return event }, })

Steps to Reproduce

I just changed the scheme to the releas and app crahes on startup however working fine with the debug scheme

Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native binary.', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native..., stack:

Expected Result

App should be working fine

Actual Result

App Crashes on startup xcode logs

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called. nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native binary.', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native..., stack: @20:290 @19:166 @461:716 h@2:1786 @460:178 h@2:1786 @431:1054 h@2:1786 @430:565 h@2:1786 @6:60 h@2:1786 d@2:1177 global code@2640:3 ' *** First throw call stack: ( 0 CoreFoundation 0x00007ff80049b761 _exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff800063904 objc_exception_throw + 48 2 App 0x00000001048dcb03 RCTFormatError + 0 3 App 0x000000010495c352 -[RCTExceptionsManager reportFatal:stack:exceptionId:extraDataAsJSON:] + 539 4 App 0x000000010495cd33 -[RCTExceptionsManager reportException:] + 1706 5 CoreFoundation 0x00007ff8004a238c invoking + 140 6 CoreFoundation 0x00007ff80049f6b3 -[NSInvocation invoke] + 302 7 CoreFoundation 0x00007ff80049f923 -[NSInvocation invokeWithTarget:] + 70 8 App 0x00000001049130cf -[RCTModuleMethod invokeWithBridge:module:arguments:] + 583 9 App 0x00000001049157fe _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 562 10 App 0x000000010491540b ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 110 11 libdispatch.dylib 0x0000000107177747 _dispatch_call_block_and_release + 12 12 libdispatch.dylib 0x00000001071789f7 _dispatch_client_callout + 8 13 libdispatch.dylib 0x00000001071808c9 _dispatch_lane_serial_drain + 1127 14 libdispatch.dylib 0x0000000107181665 _dispatch_lane_invoke + 441 15 libdispatch.dylib 0x000000010718e76e _dispatch_root_queue_drain_deferred_wlh + 318 16 libdispatch.dylib 0x000000010718db69 _dispatch_workloop_worker_thread + 590 17 libsystem_pthread.dylib 0x00000001066a8c47 _pthread_wqthread + 327 18 libsystem_pthread.dylib 0x00000001066a7b97 start_wqthread + 15 ) libc++abi: terminating due to uncaught exception of type NSException

usmanbajwa878 avatar Oct 23 '24 07:10 usmanbajwa878

Hi @usmanbajwa878, thank you for the message,

based on the error message and steps to reproduce I don't see how this relates to the Sentry RN package.

If the application is build in release mode the JS bundle is packed in the application bundle so the app should not load JS from the dev server.

Could you share more details to help us understand the issue?

krystofwoldrich avatar Oct 23 '24 09:10 krystofwoldrich

@krystofwoldrich thanks for the message

whenever I wrap metro config with 'withSentryConfig' I got this error:

File /Users/username/Library/Developer/Xcode/DerivedData/projectName/Build/Products/Release-iphonesimulator/project.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues

Here is my Metro configuration

const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const { withSentryConfig } = require('@sentry/react-native/metro')

/**
 * Metro configuration
 * https://facebook.github.io/metro/docs/configuration
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = async () => {
  const defaultConfig = await getDefaultConfig(__dirname);
  const {
    resolver: { sourceExts, assetExts },
  } = defaultConfig;

  return mergeConfig(defaultConfig, {
    transformer: {
      babelTransformerPath: require.resolve(
        'react-native-svg-transformer'
      ),
    },
    resolver: {
      assetExts: assetExts.filter((ext) => ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg'],
    },
  });
};

module.exports = withSentryConfig(config);

usmanbajwa878 avatar Oct 24 '24 07:10 usmanbajwa878

same issue here

I am using version 5.34.0 of sentry/react-native package. When I compile the application for debug, it opens and I can use it without any problems, but when I archive the application in release mode, the application does not open.

device log;

*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native binary. Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["UIManager","PlatformConstants","DeviceInfo","RNGestureHandlerModule","I18nManager","RNCAsyncStorage","NativeAnimatedModule","SourceCode","RNCSafeAreaContext","Timing","ReanimatedModule","KeyboardObserver","AccessibilityManager","RNCWebViewModule ","ImageLoader","BlobModule","ReactNativ eBlobUtil","AppState"],"TurboModules":[],"NotFound":["NativePerformanceObserverCxx","NativePerformanceCxx","NativeReactNativeFeatureFlagsCxx","RedBox","BugReporting","HeadlessJsTaskSupport","PlatformLocalStorage","RNC_AsyncSQLiteDBStorage","SoundManager"," FrameRateLogger","AccessibilityInfo","DevMenu"]}, js engine: hermes', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleR

hozdemir avatar Oct 24 '24 15:10 hozdemir

Having Same Issue...

Joshmatjjen avatar Oct 24 '24 16:10 Joshmatjjen

@krystofwoldrich thanks for the message

whenever I wrap metro config with 'withSentryConfig' I got this error:

File /Users/username/Library/Developer/Xcode/DerivedData/projectName/Build/Products/Release-iphonesimulator/project.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues

Here is my Metro configuration `const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); const { withSentryConfig } = require('@sentry/react-native/metro')

/**

  • Metro configuration
  • https://facebook.github.io/metro/docs/configuration
  • @type {import('metro-config').MetroConfig} */ const config = async () => { const defaultConfig = await getDefaultConfig(__dirname); const { resolver: { sourceExts, assetExts }, } = defaultConfig;

return mergeConfig(defaultConfig, { transformer: { babelTransformerPath: require.resolve( 'react-native-svg-transformer' ), }, resolver: { assetExts: assetExts.filter((ext) => ext !== 'svg'), sourceExts: [...sourceExts, 'svg'], }, }); };

module.exports = withSentryConfig(config); `

@usmanbajwa878 Hey! Thank you for providing the config. I assume that the issue may result from the fact, that the config you pass to withSentryConfig is not a MetroConfig object. Would you mind trying to adjust your config to something like the provided snippet below and try again? Thanks!

const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
const { withSentryConfig } = require("@sentry/react-native/metro");

const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;
/**

Metro configuration
https://facebook.github.io/metro/docs/configuration
@type {import('metro-config').MetroConfig}
*/
const config = {
  transformer: {
    babelTransformerPath: require.resolve(
      "react-native-svg-transformer/react-native" // <-- since you're on RN 0.72.6
    ),
  },
  resolver: {
    assetExts: assetExts.filter((ext) => ext !== "svg"),
    sourceExts: [...sourceExts, "svg"],
  },
};

const mergedConfig = mergeConfig(defaultConfig, config);

module.exports = withSentryConfig(mergedConfig);


rwachtler avatar Oct 24 '24 18:10 rwachtler

same issue here

I am using version 5.34.0 of sentry/react-native package. When I compile the application for debug, it opens and I can use it without any problems, but when I archive the application in release mode, the application does not open.

device log;

*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native binary. Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["UIManager","PlatformConstants","DeviceInfo","RNGestureHandlerModule","I18nManager","RNCAsyncStorage","NativeAnimatedModule","SourceCode","RNCSafeAreaContext","Timing","ReanimatedModule","KeyboardObserver","AccessibilityManager","RNCWebViewModule ","ImageLoader","BlobModule","ReactNativ eBlobUtil","AppState"],"TurboModules":[],"NotFound":["NativePerformanceObserverCxx","NativePerformanceCxx","NativeReactNativeFeatureFlagsCxx","RedBox","BugReporting","HeadlessJsTaskSupport","PlatformLocalStorage","RNC_AsyncSQLiteDBStorage","SoundManager"," FrameRateLogger","AccessibilityInfo","DevMenu"]}, js engine: hermes', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleR

Sorry, I just realized that the problem I was experiencing was not with Sentry but with Reactotron. There may be others who have similar problems. The problem was solved when I removed Reactotron.

hozdemir avatar Oct 25 '24 06:10 hozdemir

@krystofwoldrich thanks for the message whenever I wrap metro config with 'withSentryConfig' I got this error: File /Users/username/Library/Developer/Xcode/DerivedData/projectName/Build/Products/Release-iphonesimulator/project.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues Here is my Metro configuration `const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); const { withSentryConfig } = require('@sentry/react-native/metro') /**

  • Metro configuration
  • https://facebook.github.io/metro/docs/configuration
  • @type {import('metro-config').MetroConfig} */ const config = async () => { const defaultConfig = await getDefaultConfig(__dirname); const { resolver: { sourceExts, assetExts }, } = defaultConfig;

return mergeConfig(defaultConfig, { transformer: { babelTransformerPath: require.resolve( 'react-native-svg-transformer' ), }, resolver: { assetExts: assetExts.filter((ext) => ext !== 'svg'), sourceExts: [...sourceExts, 'svg'], }, }); }; module.exports = withSentryConfig(config); `

@usmanbajwa878 Hey! Thank you for providing the config. I assume that the issue may result from the fact, that the config you pass to withSentryConfig is not a MetroConfig object. Would you mind trying to adjust your config to something like the provided snippet below and try again? Thanks!

const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config"); const { withSentryConfig } = require("@sentry/react-native/metro");

const defaultConfig = getDefaultConfig(__dirname); const { assetExts, sourceExts } = defaultConfig.resolver; /**

Metro configuration https://facebook.github.io/metro/docs/configuration @type {import('metro-config').MetroConfig} */ const config = { transformer: { babelTransformerPath: require.resolve( "react-native-svg-transformer/react-native" // <-- since you're on RN 0.72.6 ), }, resolver: { assetExts: assetExts.filter((ext) => ext !== "svg"), sourceExts: [...sourceExts, "svg"], }, };

const mergedConfig = mergeConfig(defaultConfig, config);

module.exports = withSentryConfig(mergedConfig);

Still not working

usmanbajwa878 avatar Oct 25 '24 11:10 usmanbajwa878

same issue here I am using version 5.34.0 of sentry/react-native package. When I compile the application for debug, it opens and I can use it without any problems, but when I archive the application in release mode, the application does not open. device log; *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native binary. Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["UIManager","PlatformConstants","DeviceInfo","RNGestureHandlerModule","I18nManager","RNCAsyncStorage","NativeAnimatedModule","SourceCode","RNCSafeAreaContext","Timing","ReanimatedModule","KeyboardObserver","AccessibilityManager","RNCWebViewModule ","ImageLoader","BlobModule","ReactNativ eBlobUtil","AppState"],"TurboModules":[],"NotFound":["NativePerformanceObserverCxx","NativePerformanceCxx","NativeReactNativeFeatureFlagsCxx","RedBox","BugReporting","HeadlessJsTaskSupport","PlatformLocalStorage","RNC_AsyncSQLiteDBStorage","SoundManager"," FrameRateLogger","AccessibilityInfo","DevMenu"]}, js engine: hermes', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleR

Sorry, I just realized that the problem I was experiencing was not with Sentry but with Reactotron. There may be others who have similar problems. The problem was solved when I removed Reactotron.

It's great that you've been able to solve the issue! 💯 How did you determine that the problem wasn't related to Sentry?

usmanbajwa878 avatar Oct 25 '24 11:10 usmanbajwa878

@krystofwoldrich thanks for the message whenever I wrap metro config with 'withSentryConfig' I got this error: File /Users/username/Library/Developer/Xcode/DerivedData/projectName/Build/Products/Release-iphonesimulator/project.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues Here is my Metro configuration `const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); const { withSentryConfig } = require('@sentry/react-native/metro') /**

  • Metro configuration
  • https://facebook.github.io/metro/docs/configuration
  • @type {import('metro-config').MetroConfig} */ const config = async () => { const defaultConfig = await getDefaultConfig(__dirname); const { resolver: { sourceExts, assetExts }, } = defaultConfig;

return mergeConfig(defaultConfig, { transformer: { babelTransformerPath: require.resolve( 'react-native-svg-transformer' ), }, resolver: { assetExts: assetExts.filter((ext) => ext !== 'svg'), sourceExts: [...sourceExts, 'svg'], }, }); }; module.exports = withSentryConfig(config); `

@usmanbajwa878 Hey! Thank you for providing the config. I assume that the issue may result from the fact, that the config you pass to withSentryConfig is not a MetroConfig object. Would you mind trying to adjust your config to something like the provided snippet below and try again? Thanks! const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config"); const { withSentryConfig } = require("@sentry/react-native/metro"); const defaultConfig = getDefaultConfig(__dirname); const { assetExts, sourceExts } = defaultConfig.resolver; /** Metro configuration https://facebook.github.io/metro/docs/configuration @type {import('metro-config').MetroConfig} */ const config = { transformer: { babelTransformerPath: require.resolve( "react-native-svg-transformer/react-native" // <-- since you're on RN 0.72.6 ), }, resolver: { assetExts: assetExts.filter((ext) => ext !== "svg"), sourceExts: [...sourceExts, "svg"], }, }; const mergedConfig = mergeConfig(defaultConfig, config); module.exports = withSentryConfig(mergedConfig);

Still not working

Thanks for the feedback @usmanbajwa878 ! Just to clarify, if you use the metro.config I've provided earlier, do you still get the error:

File /Users/username/Library/Developer/Xcode/DerivedData/projectName/Build/Products/Release-iphonesimulator/project.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here:

or rather the one below (as stated in your initial issue description)

A module failed to load due to an error and AppRegistry.registerComponent wasn't called.
nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint
nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint
*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native binary.', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native..., stack:

rwachtler avatar Oct 25 '24 11:10 rwachtler

@krystofwoldrich thanks for the message whenever I wrap metro config with 'withSentryConfig' I got this error: File /Users/username/Library/Developer/Xcode/DerivedData/projectName/Build/Products/Release-iphonesimulator/project.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: https://github.com/facebook/react-native/issues Here is my Metro configuration `const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); const { withSentryConfig } = require('@sentry/react-native/metro') /**

  • Metro configuration
  • https://facebook.github.io/metro/docs/configuration
  • @type {import('metro-config').MetroConfig} */ const config = async () => { const defaultConfig = await getDefaultConfig(__dirname); const { resolver: { sourceExts, assetExts }, } = defaultConfig;

return mergeConfig(defaultConfig, { transformer: { babelTransformerPath: require.resolve( 'react-native-svg-transformer' ), }, resolver: { assetExts: assetExts.filter((ext) => ext !== 'svg'), sourceExts: [...sourceExts, 'svg'], }, }); }; module.exports = withSentryConfig(config); `

@usmanbajwa878 Hey! Thank you for providing the config. I assume that the issue may result from the fact, that the config you pass to withSentryConfig is not a MetroConfig object. Would you mind trying to adjust your config to something like the provided snippet below and try again? Thanks! const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config"); const { withSentryConfig } = require("@sentry/react-native/metro"); const defaultConfig = getDefaultConfig(__dirname); const { assetExts, sourceExts } = defaultConfig.resolver; /** Metro configuration https://facebook.github.io/metro/docs/configuration @type {import('metro-config').MetroConfig} */ const config = { transformer: { babelTransformerPath: require.resolve( "react-native-svg-transformer/react-native" // <-- since you're on RN 0.72.6 ), }, resolver: { assetExts: assetExts.filter((ext) => ext !== "svg"), sourceExts: [...sourceExts, "svg"], }, }; const mergedConfig = mergeConfig(defaultConfig, config); module.exports = withSentryConfig(mergedConfig);

Still not working

Thanks for the feedback @usmanbajwa878 ! Just to clarify, if you use the metro.config I've provided earlier, do you still get the error:

File /Users/username/Library/Developer/Xcode/DerivedData/projectName/Build/Products/Release-iphonesimulator/project.app/main.jsbundle does not exist. This must be a bug with React Native, please report it here: or rather the one below (as stated in your initial issue description)

A module failed to load due to an error and AppRegistry.registerComponent wasn't called. nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native binary.', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native..., stack:

I still get this error A module failed to load due to an error and AppRegistry.registerComponent wasn't called.

nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native binary.', reason: 'Unhandled JS Exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevMenu' could not be found. Verify that a module by this name is registered in the native..., stack:

usmanbajwa878 avatar Oct 25 '24 11:10 usmanbajwa878

That's strange. DevMenu is one of the internal core components of React Native and shouldn't be loaded into prod bundle at all (that's probably why you get the error, since it can't access it in "Release"). Sorry for going back and forth on this, but are you 100% positive that this appears as soon as you use withSentryConfig(...) only? What I mean is - can you build and successfully run a "Release" build without it? Just trying to get as much info as possible in order to track it down.

Also, there seems to be a similar discussion over in the react-native repo, so probably something that might be worthy to follow.

rwachtler avatar Oct 25 '24 12:10 rwachtler

@rwachtler Yes the Issue is not only with withSentryConfig but even if I remove that app crashes later I have found this script has been added by sentry wizard in Build phases of Bundle React Native Code and Images

`set -e

WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh" REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT "/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE"" `

usmanbajwa878 avatar Oct 26 '24 17:10 usmanbajwa878

Reactotron was the problem for me.

Reactotron requires DevMenu no matter the environment. Trying to get DevMenu in production results in a crash as React Native do not include it in production. I did this patch

diff --git a/src/plugins/devTools.ts b/src/plugins/devTools.ts
index c2af7abeb22401099dc928ee866a63887708d21e..9786e2ecf9974051361f091a87b9f5e48c13c9d5 100644
--- a/src/plugins/devTools.ts
+++ b/src/plugins/devTools.ts
@@ -2,7 +2,12 @@ import { Platform } from "react-native"
 import type { ReactotronCore, Plugin } from "reactotron-core-client"
 
 let DevMenu = { show: () => {}, reload: () => {} }
-if (Platform.OS === "ios") {
+
+/** Do not attempt to retrieve the React Native DevMenu in other environments than __DEV__.
+ * Otherwise, React Native will throw an error as DevMenu is not included in
+ * production builds.
+ */
+if (Platform.OS === "ios" && __DEV__) {
   DevMenu = require("react-native/Libraries/NativeModules/specs/NativeDevMenu")
 }
 
 

mgltopdk avatar Oct 28 '24 18:10 mgltopdk

@usmanbajwa878 Are you using Reactotron? If so, have you tried to apply the suggestion above? There is an open issue in their repo as well - https://github.com/infinitered/reactotron/issues/1513

rwachtler avatar Oct 28 '24 21:10 rwachtler

Yes I am using the reactotron-react-native package. Thanks for the support @rwachtler I will apply the above suggestion.

usmanbajwa878 avatar Oct 29 '24 07:10 usmanbajwa878

Thank you everyone for the comments and suggestions which helped the quick resolution.

We will close the issue since the crash was caused by https://github.com/infinitered/reactotron/issues/1513

krystofwoldrich avatar Oct 29 '24 13:10 krystofwoldrich

Reactotron was the problem for me.

Reactotron requires DevMenu no matter the environment. Trying to get DevMenu in production results in a crash as React Native do not include it in production. I did this patch

diff --git a/src/plugins/devTools.ts b/src/plugins/devTools.ts index c2af7abeb22401099dc928ee866a63887708d21e..9786e2ecf9974051361f091a87b9f5e48c13c9d5 100644 --- a/src/plugins/devTools.ts +++ b/src/plugins/devTools.ts @@ -2,7 +2,12 @@ import { Platform } from "react-native" import type { ReactotronCore, Plugin } from "reactotron-core-client"

let DevMenu = { show: () => {}, reload: () => {} } -if (Platform.OS === "ios") { + +/** Do not attempt to retrieve the React Native DevMenu in other environments than DEV.

    • Otherwise, React Native will throw an error as DevMenu is not included in
    • production builds.
  • */ +if (Platform.OS === "ios" && DEV) { DevMenu = require("react-native/Libraries/NativeModules/specs/NativeDevMenu") }

Oh, even I thought a __DEV__ should be there at first, as mentioned in the issue. But then I thought in our code, we are initializing it using

if (__DEV__) {
  // eslint-disable-next-line global-require
  require('@redux/ReactotronConfig');
}

So, it shouldn't get initialized. And being a debug tool, it shouldn't be bundled up in the release build. Does this mean we should remove this package whenever we create a Play Store or App Store build to avoid an unnecessary increase in aab/ipa size?

jerinjohnk avatar Oct 29 '24 18:10 jerinjohnk