iosxcodestoryboardios-simulator

Why is my iOS app build working on a real device, but crashing on a simulator?


I am trying to test a feature that requires me to simulate my location which is not possible on a real device as far as I know. This is why I now need to build my app, that has been working for many weeks and hundreds of builds on my real device, on a simulator. However, as soon as I start the app in the simulator (or it gets started by Xcode), the app crashes with this log:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle </Users/[...]/Library/Developer/CoreSimulator/Devices/7F88C881-9905-4665-AC11-282A5171CCAC/data/Containers/Bundle/Application/65ABEA43-53A1-4181-A8F4-AD87D9CCA49B/[...].app> (loaded)'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010a3677d4 __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x000000010681b7cc objc_exception_throw + 72
    2   UIKitCore                           0x0000000145d7f1f0 -[UIStoryboard name] + 0
    3   UIKitCore                           0x0000000145bd6810 -[UIApplication _storyboardInitialMenu] + 112
    4   UIKitCore                           0x0000000145bf3544 -[UIApplication buildMenuWithBuilder:] + 44
    5   UIKitCore                           0x00000001460f2cec -[UIMenuSystem _buildMenuWithBuilder:fromResponderChain:atLocation:inCoordinateSpace:] + 92
    6   UIKitCore                           0x000000014501b900 -[_UIMainMenuSystem _buildMenuWithBuilder:fromResponderChain:atLocation:inCoordinateSpace:] + 112
    7   UIKitCore                           0x00000001460f2c2c -[UIMenuSystem _newBuilderFromResponderChain:atLocation:inCoordinateSpace:] + 96
    8   UIKitCore                           0x000000014501b7d4 -[_UIMainMenuSystem _automaticallyRebuildIfNeeded] + 172
    9   UIKitCore                           0x000000014501b80c -[_UIMainMenuSystem _keyCommands] + 20
    10  UIKitCore                           0x0000000145beeeec -[UIApplication _keyCommands] + 80
    11  UIKitCore                           0x0000000145bffab0 -[UIResponder _enumerateKeyCommandsInChainWithOptions:usingBlock:] + 436
    12  UIKitCore                           0x0000000145beeb74 -[UIApplication _immediatelyUpdateSerializableKeyCommandsForResponder:] + 164
    13  UIKitCore                           0x00000001460eb9a8 -[_UIAfterCACommitBlock run] + 64
    14  UIKitCore                           0x00000001460ebdbc -[_UIAfterCACommitQueue flush] + 164
    15  UIKitCore                           0x0000000145bdf54c _runAfterCACommitDeferredBlocks + 256
    16  UIKitCore                           0x0000000145bd1028 _cleanUpAfterCAFlushAndRunDeferredBlocks + 76
    17  CoreFoundation                      0x000000010a2c7134 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
    18  CoreFoundation                      0x000000010a2c6898 __CFRunLoopDoBlocks + 348
    19  CoreFoundation                      0x000000010a2c1450 __CFRunLoopRun + 808
    20  CoreFoundation                      0x000000010a2c0cec CFRunLoopRunSpecific + 536
    21  GraphicsServices                    0x000000011f51ad00 GSEventRunModal + 164
    22  UIKitCore                           0x0000000145bd27d4 -[UIApplication _run] + 796
    23  UIKitCore                           0x0000000145bd6ba0 UIApplicationMain + 124
    24  UIKitCore                           0x0000000144f9cf1c block_destroy_helper.14 + 9560
    25  [...].debug.dylib                    0x0000000107067cdc $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 128
    26  [...].debug.dylib                    0x0000000107067c4c $s4[...]11AppDelegateC5$mainyyFZ + 44
    27  [...].debug.dylib                    0x0000000107067d58 __debug_main_executable_dylib_entry_point + 28
    28  dyld                                0x00000001046113d4 start_sim + 20
    29  ???                                 0x000000010470ab98 0x0 + 4369460120
)
libc++abi: terminating due to uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle </Users/[...]/Library/Developer/CoreSimulator/Devices/7F88C881-9905-4665-AC11-282A5171CCAC/data/Containers/Bundle/Application/65ABEA43-53A1-4181-A8F4-AD87D9CCA49B/[...].app> (loaded)'
terminating due to uncaught exception of type NSException
CoreSimulator 1010.15 - Device: iPhone 16 Pro (7F88C881-9905-4665-AC11-282A5171CCAC) - Runtime: iOS 18.5 (22F77) - DeviceType: iPhone 16 Pro

It seems to crash because my app is looking for a storyboard file, which I have removed from day one, because I am doing everything programatically.

Steps I have done:

  1. Remove the reference to storyboard in Launch Screen. -> Was already empty
  2. Check for any reference to "Main" or Storyboard in my Info.plist -> Nothing
  3. Checked if the deployment target was set to universal or anything other than iPhone -> Was already the case.

I don't know what else I can check. AI is telling me that it might be a dependency that is trying to reference Storyboard. If so, how do I find out which one it is?


Solution

  • From your message, I see that you’ve already removed the storyboard reference from the main Info.plist. However, you also need to delete the value for Main storyboard file base name from your target’s Info tab. This ensures the app doesn’t attempt to load a storyboard at launch.

    1. Select your target in the Project Navigator.

    2. Go to the Info tab.

    3. Find the key: Main storyboard file base name.

    4. Delete the value (usually "Main"), or remove the entire key with name Main storyboard file base name.

      I hope it helps!.