react-native ios app crashes immediately on simulators and TestFlight installs

I  am completely at a loss here - I have a react native app created within expo. It runs perfectly well with expo go. I then built it using eas on my Mac (latest Ventura OS installed) and posted it to app store connect and installed it through TestFlight - it crashed immediately. I'm VERY new to this so it took me a long time to figure out how to troubleshoot this but I ended up finding this in the crash logs:

Thread 2 name: Dispatch queue: com.facebook.react.ExceptionsManagerQueue Thread 2 Crashed: 0 libsystem_kernel.dylib 0x2076d8200 __pthread_kill + 8 1 libsystem_pthread.dylib 0x217b3a1ac pthread_kill + 268 2 libsystem_c.dylib 0x1d2111c8c abort + 180 3 libc++abi.dylib 0x217a7ab8c abort_message + 132 4 libc++abi.dylib 0x217a6aa80 demangling_terminate_handler() + 336 5 libobjc.A.dylib 0x1c3e11d3c _objc_terminate() + 144 6 libc++abi.dylib 0x217a79f28 std::__terminate(void (*)()) + 20 7 libc++abi.dylib 0x217a79ec4 std::terminate() + 56 8 libdispatch.dylib 0x1d20adff0 _dispatch_client_callout + 40 9 libdispatch.dylib 0x1d20b5694 _dispatch_lane_serial_drain + 672 10 libdispatch.dylib 0x1d20b61e0 _dispatch_lane_invoke + 384 11 libdispatch.dylib 0x1d20c0e10 _dispatch_workloop_worker_thread + 652 12 libsystem_pthread.dylib 0x217b33df8 _pthread_wqthread + 288 13 libsystem_pthread.dylib 0x217b33b98 start_wqthread + 8

And:

Thread 2 crashed with ARM Thread State (64-bit): x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000000000000 x4: 0x0000000217a7e0f5 x5: 0x000000016b4c6430 x6: 0x000000000000006e x7: 0xffffffff00000600 x8: 0xb1cfaa93a40be1da x9: 0xb1cfaa92cf4791da x10: 0x0000000000000200 x11: 0x000000000000000b x12: 0x000000000000000b x13: 0x00000000001ff800 x14: 0x00000000000007fb x15: 0x000000008c033819 x16: 0x0000000000000148 x17: 0x000000016b4c7000 x18: 0x0000000000000000 x19: 0x0000000000000006 x20: 0x0000000000001603 x21: 0x000000016b4c70e0 x22: 0x0000000000000000 x23: 0x000000016b4c70e0 x24: 0x0000000000000000 x25: 0x0000000280c888e8 x26: 0x0000000000000114 x27: 0x0000000000000000 x28: 0x0000000283787840 fp: 0x000000016b4c63a0 lr: 0x0000000217b3a1ac sp: 0x000000016b4c6380 pc: 0x00000002076d8200 cpsr: 0x40001000 far: 0x000000021e5abf50 esr: 0x56000080 Address size fault

I  spent an entire day searching for causes surrounding these errors - there were references to this but nothing related to what I was doing. I then went back to the basics - literally:

npx create-expo-app TestApp

eas build:configure

eas build --platform ios

And loaded this into a simulator (downloaded the ipa file, changed it to a .zip file, transferred the app file to the simulator) and it immediately crashed again. I've used various versions of expo, node, eas cli, etc - all giving me the same results. I tried using ErrorUtils to send an error to my node server but that didn't work (I might have set it up wrong). I'm not sure how to proceed in troubleshooting this. It seems like the basic process of creating an expo app and having it installable in a simulator or an iPhone isn't working for me. I haven't used (nor do I know how to) Xcode much outside of using the simulators. Any help would be VERY MUCH appreciated.

Answered by ebarnett32 in 741259022

After painfully starting from a bare-bones react-native expo app and adding functionality bit by bit, I found the issue was the stack navigator code. Once I had it narrowed down to that, I found that I missed installing the support packages necessary for stack navigation:

npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

And that you have to include:

import 'react-native-gesture-handler';

At the top of your App.js file - but in my case, I had two files with stack navigation so it wasn't enough to include that import just in App.js but also in that other file. Once I did this, no more crashes!

Just to update this - it tuns out the ipa file that I generated from the base expo template was fine...the hack I found to unzip it and transfer the app to the simulator doesn't work. Once I "published" that base app to TestFlight it loaded find on my iPhone. So, there is something specifically wrong with my app - what I have no idea. And, I'm not sure how to proceed in troubleshooting other than start with the base app, keep adding code, and keep building/publishing.

Just to update this - it tuns out the ipa file that I generated from the base expo template was fine...the hack I found to unzip it and transfer the app to the simulator doesn't work. Once I "published" that base app to TestFlight it loaded find on my iPhone. So, there is something specifically wrong with my app - what I have no idea. And, I'm not sure how to proceed in troubleshooting other than start with the base app, keep adding code, and keep building/publishing.

"Once I "published" that base app to TestFlight it loaded find on my iPhone."

If the app loads fine on the iPhone, then what is actually the problem?

Accepted Answer

After painfully starting from a bare-bones react-native expo app and adding functionality bit by bit, I found the issue was the stack navigator code. Once I had it narrowed down to that, I found that I missed installing the support packages necessary for stack navigation:

npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

And that you have to include:

import 'react-native-gesture-handler';

At the top of your App.js file - but in my case, I had two files with stack navigation so it wasn't enough to include that import just in App.js but also in that other file. Once I did this, no more crashes!

Ran into the same problem. I could replicate it locally by using npx expo start --no-dev --clear. Works for both Expo Go and the development build.

I then replace the contents of app.js with vanilla project code. Then I started adding the imports one by one. It quickly became apparent that <TouchableOpacity> was the culprit. replace <TouchableOpacity> with <Pressable> and removed import { TouchableOpacity } from 'react-native-gesture-handler'; in all components.

This resolved the issue.

Hello, I have run into a similar problem. In my expo application, I upgraded to React Navigation version 6. My application worked in development but crashed in production. The problem did appear to be related to the stack navigator code, as user ebarnett32 discovered. Declaring import 'react-native-gesture-handler'; at the top of all React components that used the stack navigator appears to have fixed my problem. However, I also have imported it in my application entry file (index.js or App.js). I have also removed all uses of the TouchableOpacity components imported from react-native-gesture-handler, replacing them with Pressable from the react native package, as suggested by sjoerdsantema. Therefore, it may have been a combination of the previous suggestions that fixed my issue.

Just a heads up. I had a similar problem. Developed an App with Expo, used the EAS to build and submit. All worked fine until I updated the expo cli. Now it crashes at start. I tried what everyone here said. Still works fine on Expo Dev Client build and crashes silently upon building. I am sure that your "fixes" even though they all sounded like work arounds for some bug in the development tools. I am not sure I have the energy to start from bare bones and work my way up. But I think that is what is needed. Just a heads up, I like to use a binary work my way up. Don't start with barebones - but start half way, and then half again. Given the size of my code base that will be necessary.

For me it was exactly adding import 'react-native-gesture-handler'; at the top of the main navigator using a stack navigator as well. Why I cannot say. npx expo start --no-dev --minify --clear is supposed to reproduce the issue, but for me it did not. Only in TestFlight I could see the crash. Very annoying.

I am having the same issue. My app was working with eas local building and on simulator but then around the time I upgraded to eas-cli 5.4.0 the production built with eas --local stopped working. It crashes immediately on app start on device. The development build and the simulator build work just fine. I have gone back in time to known good points in git history but I still get the same error. I have downgraded to eas-cli 5.3.0 and 5.2.0 and still get the same thing. I can't figure out to read the .ips crash logs because they need the symbol files to be human readable. I did a remove build for version in git that was not working with --local flag but it work remotely on xpo remote builds. I am not sure why yet. It is very frustrating

react-native ios app crashes immediately on simulators and TestFlight installs
 
 
Q