React-Native iOS app is crashing immediately upon launch when creating development build

I have created an app for iOS using React Native. I've gotten the app to a point where it works on the iPhone simulator via the Expo App. It even works when creating a build of the app to distribute using TestFlight. Now, I want to add Google Ads into the app. However, I've learned that Google Ads won't work via an Expo build. Instead one has to create a development build to test the ads in the app and see how they look.

I've also finally been able to compile a successful development build using eas (expo application services). When I install the app on the simulator and try to open it however, the app crashes almost immediately and I don't know why. I have tried deciphering the symbolicated crash report, but I have not been able to figure out what could be causing the error. It looks like it has something to do with the user interface.

Below is the thread where the app crashes:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x11324a14a __pthread_kill + 10
1   libsystem_pthread.dylib       	       0x1132abebd pthread_kill + 262
2   libsystem_c.dylib             	    0x7ff80016dd1c abort + 133
3   libc++abi.dylib               	    0x7ff8002c6d12 abort_message + 241
4   libc++abi.dylib               	    0x7ff8002b951a demangling_terminate_handler() + 266
5   libobjc.A.dylib               	    0x7ff800061fba _objc_terminate() + 96
6   libc++abi.dylib               	    0x7ff8002c616b std::__terminate(void (*)()) + 6
7   libc++abi.dylib               	    0x7ff8002c6126 std::terminate() + 54
8   libdispatch.dylib             	    0x7ff8001796ec _dispatch_client_callout + 28
9   libdispatch.dylib             	    0x7ff80017d1e2 _dispatch_block_invoke_direct + 508
10  FrontBoardServices            	    0x7ff807a8b3a7 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
11  FrontBoardServices            	    0x7ff807a8b281 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 188
12  FrontBoardServices            	    0x7ff807a8b3cf -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 19
13  CoreFoundation                	    0x7ff800429ff3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14  CoreFoundation                	    0x7ff800429f35 __CFRunLoopDoSource0 + 157
15  CoreFoundation                	    0x7ff800429732 __CFRunLoopDoSources0 + 215
16  CoreFoundation                	    0x7ff800423e67 __CFRunLoopRun + 919
17  CoreFoundation                	    0x7ff8004236ed CFRunLoopRunSpecific + 557
18  GraphicsServices              	    0x7ff8103ba08f GSEventRunModal + 137
19  UIKitCore                     	    0x7ff805cdf6ee -[UIApplication _run] + 972
20  UIKitCore                     	    0x7ff805ce416e UIApplicationMain + 123
21  LeftOff                       	       0x10f870380 main + 96
22  dyld_sim                      	       0x112d3a3e0 start_sim + 10
23  dyld                          	       0x113d57366 start + 1942

I have been trying to solve this for some days now and could really use some help. I have tried changing versions of dependencies in my app too, with a focus on those that manage the UI. For example, I have changed packages such as react-native-ranimated, react-navigation/stack, react-native-gesture-handler, and react-native-screens to name a few. Nothing has worked so far. Please help.

Answered by CodeWorker in 794325022

Thank you for your response!

TLDR: I needed to use npx expo prebuild --clean to clear information related to previous builds I had created.

Full version: Your response gave me a hint into what was going wrong. Just as you said, the RCTAppDelegate (which stands for React App Delegate I believe) was causing the NSException (or NeXTSTEP Exception) to appear. I wondered why the RCTAppDelegate would cause an exception. After hours of searching and doing research on RN, Apple crash reports, etc. I thought to myself: maybe the bundleURL is wrong or missing, thus causing the syntax or language exception.

It turns out, I needed to use npx expo prebuild --clean to clear information related to previous builds I had created. I also removed all of the previous zip files and builds from my app's root directory. After that, I could use eas build --profile dev-sim --platform ios --local and the build worked! I think RCTAppDelegate was trying to find the correct bundleURL, but got confused when it found multiple bundleURLs in the root directory.

Please post a full Apple crash report, per the advice in Posting a Crash Report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you for your response. I have attached the full crash report to this response.

Thanks for the crash report.

The presence of the Last Exception Backtrace section indicates that your app has crashed due to an unhandled language exception. Consider this:

Last Exception Backtrace:
0   CoreFoundation  … __exceptionPreprocess + 226
1   libobjc.A.dylib … objc_exception_throw + 48
2   CoreFoundation  … -[NSException initWithCoder:] + 0
3   LlllOoo         … -[RCTAppDelegate bundleURL] + 52
4   LlllOoo         … -[EXAppDelegateWrapper createRCTRootViewFactory] + 65
5   LlllOoo         … -[RCTAppDelegate application:didFinishLaunchingWithOptions:] + 223
6   LlllOoo         … -[EXAppDelegateWrapper application:didFinishLaunchingWithOptions:] + 112
7   LlllOoo         … -[AppDelegate application:didFinishLaunchingWithOptions:] + 176
8   UIKitCore       … -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 297
…

In frame 8 UIKit is calling your app’s -application:didFinishLaunchingWithOptions: delegate method (frame 7). That’s done a bunch of stuff and then, in frame 2, it’s throwing that exception.

It’s hard to say why it’s done that because this isn’t Apple code. It looks like the exception is being thrown by your third-party runtime (RCTAppDelegate), so I recommend that you escalate this for the support channel for that tool.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Thank you for your response!

TLDR: I needed to use npx expo prebuild --clean to clear information related to previous builds I had created.

Full version: Your response gave me a hint into what was going wrong. Just as you said, the RCTAppDelegate (which stands for React App Delegate I believe) was causing the NSException (or NeXTSTEP Exception) to appear. I wondered why the RCTAppDelegate would cause an exception. After hours of searching and doing research on RN, Apple crash reports, etc. I thought to myself: maybe the bundleURL is wrong or missing, thus causing the syntax or language exception.

It turns out, I needed to use npx expo prebuild --clean to clear information related to previous builds I had created. I also removed all of the previous zip files and builds from my app's root directory. After that, I could use eas build --profile dev-sim --platform ios --local and the build worked! I think RCTAppDelegate was trying to find the correct bundleURL, but got confused when it found multiple bundleURLs in the root directory.

React-Native iOS app is crashing immediately upon launch when creating development build
 
 
Q