title: IOS App crashes when run on physical device, runs when simulating
body: <p>Recently updated my iPhone and Xcode and I'm having some problems running my app on my physical device. When I run it on the simulator built into Xcode it runs fine, no drama. </p>
  
  <p>However, when I launch it on my physical device it crashes, with no error code apart from: </p>
  
  <p>Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)</p>
  
  <p><a href="https://i.stack.imgur.com/6CzlQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6CzlQ.png" alt="Crash Message Example"></a>
  Output right before it crashes (by the crash, I just mean it proceeds to land on an empty white page):</p>
  
  <pre><code>2018-04-14 20:34:17.840760+1200 MPM[1520:450438] 4.11.0 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40100000 started
  2018-04-14 20:34:17.840831+1200 MPM[1520:450438] 4.11.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ...)
  2018-04-14 20:34:18.603581+1200 MPM[1520:450344] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
  2018-04-14 20:34:18.605545+1200 MPM[1520:450344] [MC] Reading from public effective user settings.
  2018-04-14 20:34:18.635084+1200 MPM[1520:450442] TIC Read Status [3:0x0]: 1:57
  2018-04-14 20:34:18.635136+1200 MPM[1520:450442] TIC Read Status [3:0x0]: 1:57
  2018-04-14 20:34:18.848190+1200 MPM[1520:450455] TIC Read Status [1:0x0]: 1:57
  2018-04-14 20:34:18.848245+1200 MPM[1520:450455] TIC Read Status [1:0x0]: 1:57
  2018-04-14 20:34:19.214792+1200 MPM[1520:450438] TIC Read Status [5:0x0]: 1:57
  2018-04-14 20:34:19.214887+1200 MPM[1520:450438] TIC Read Status [5:0x0]: 1:57
  2018-04-14 20:34:19.224559+1200 MPM[1520:450438] TIC Read Status [4:0x0]: 1:57
  2018-04-14 20:34:19.224638+1200 MPM[1520:450438] TIC Read Status [4:0x0]: 1:57
  2018-04-14 20:34:29.910232+1200 MPM[1520:450344] [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction
  2018-04-14 20:34:29.914038+1200 MPM[1520:450445] TIC Read Status [6:0x0]: 1:57
  2018-04-14 20:34:29.914066+1200 MPM[1520:450445] TIC Read Status [6:0x0]: 1:57
  2018-04-14 20:34:30.533306+1200 MPM[1520:450442] TIC Read Status [7:0x0]: 1:57
  2018-04-14 20:34:30.533410+1200 MPM[1520:450442] TIC Read Status [7:0x0]: 1:57
  2018-04-14 20:34:30.659726+1200 MPM[1520:450619] TIC Read Status [8:0x0]: 1:57
  2018-04-14 20:34:30.659861+1200 MPM[1520:450619] TIC Read Status [8:0x0]: 1:57
  2018-04-14 20:34:31.336759+1200 MPM[1520:450551] TIC Read Status [9:0x0]: 1:57
  2018-04-14 20:34:31.336833+1200 MPM[1520:450551] TIC Read Status [9:0x0]: 1:57
  2018-04-14 20:34:35.499882+1200 MPM[1520:450551] TIC Read Status [10:0x0]: 1:57
  2018-04-14 20:34:35.499977+1200 MPM[1520:450551] TIC Read Status [10:0x0]: 1:57
  2018-04-14 20:34:37.613908+1200 MPM[1520:450619] TIC Read Status [2:0x1d416ff00]: 1:57
  2018-04-14 20:34:37.613974+1200 MPM[1520:450619] TIC Read Status [2:0x1d416ff00]: 1:57
  (lldb) 
  </code></pre>
  
  <p>Anyone have any ideas here? I'm completely stumped at this point. Even any way of finding a more detailed crash message!</p>
  
  <p>Managed to get this output after rebooting the physical device and running again </p>
  
  <pre><code>018-04-14 20:49:32.065664+1200 MPM[259:6493] 4.11.0 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40100000 started
  2018-04-14 20:49:32.065727+1200 MPM[259:6493] 4.11.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ...)
  2018-04-14 20:49:32.313875+1200 MPM[259:6335] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
  2018-04-14 20:49:32.314851+1200 MPM[259:6335] [MC] Reading from public effective user settings.
  2018-04-14 20:49:32.629858+1200 MPM[259:6496] TIC Read Status [1:0x0]: 1:57
  2018-04-14 20:49:32.629930+1200 MPM[259:6496] TIC Read Status [1:0x0]: 1:57
  2018-04-14 20:49:32.769607+1200 MPM[259:6496] TIC Read Status [2:0x0]: 1:57
  2018-04-14 20:49:32.769667+1200 MPM[259:6496] TIC Read Status [2:0x0]: 1:57
  2018-04-14 20:49:36.901270+1200 MPM[259:6496] [] tcp_timers tcp[3] retransmit SYN 3
  2018-04-14 20:49:36.983026+1200 MPM[259:6496] [] tcp_timers tcp[3] retransmit SYN 4
  2018-04-14 20:49:37.065395+1200 MPM[259:6496] [] tcp_timers tcp[3] retransmit SYN 5
  2018-04-14 20:49:37.144244+1200 MPM[259:6496] [] tcp_timers tcp[3] retransmit SYN 6
  2018-04-14 20:49:37.305612+1200 MPM[259:6496] [] tcp_timers tcp[3] retransmit SYN 7
  2018-04-14 20:49:37.620292+1200 MPM[259:6496] [] tcp_timers tcp[3] retransmit SYN 8
  2018-04-14 20:49:38.213878+1200 MPM[259:6335] [Warning] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (&lt;SFAuthenticationViewController: 0x13c870600&gt;)
  2018-04-14 20:49:42.662630+1200 MPM[259:6496] TIC Read Status [3:0x0]: 1:57
  2018-04-14 20:49:42.662738+1200 MPM[259:6496] TIC Read Status [3:0x0]: 1:57
  2018-04-14 20:49:43.125171+1200 MPM[259:6521] [] tcp_timers tcp[4] retransmit SYN 3
  2018-04-14 20:49:43.207601+1200 MPM[259:6521] [] tcp_timers tcp[4] retransmit SYN 4
  2018-04-14 20:49:43.290081+1200 MPM[259:6521] [] tcp_timers tcp[4] retransmit SYN 5
  2018-04-14 20:49:43.369637+1200 MPM[259:6521] [] tcp_timers tcp[4] retransmit SYN 6
  2018-04-14 20:49:43.530976+1200 MPM[259:6521] [] tcp_timers tcp[4] retransmit SYN 7
  2018-04-14 20:49:43.846252+1200 MPM[259:6521] [] tcp_timers tcp[4] retransmit SYN 8
  2018-04-14 20:49:44.475763+1200 MPM[259:6521] [] tcp_timers tcp[4] retransmit SYN 9
  2018-04-14 20:49:47.529539+1200 MPM[259:6493] [] tcp_timers tcp[5] retransmit SYN 3
  2018-04-14 20:49:47.603154+1200 MPM[259:6493] [] tcp_timers tcp[5] retransmit SYN 4
  2018-04-14 20:49:47.679578+1200 MPM[259:6493] [] tcp_timers tcp[5] retransmit SYN 5
  2018-04-14 20:49:47.756423+1200 MPM[259:6493] [] tcp_timers tcp[5] retransmit SYN 6
  2018-04-14 20:49:47.905496+1200 MPM[259:6493] [] tcp_timers tcp[5] retransmit SYN 7
  2018-04-14 20:49:48.257627+1200 MPM[259:6491] TIC Read Status [4:0x0]: 1:57
  2018-04-14 20:49:48.257731+1200 MPM[259:6491] TIC Read Status [4:0x0]: 1:57
  2018-04-14 20:49:49.175122+1200 MPM[259:6491] TIC Read Status [5:0x0]: 1:57
  2018-04-14 20:49:49.175221+1200 MPM[259:6491] TIC Read Status [5:0x0]: 1:57
  2018-04-14 20:50:13.674495+1200 MPM[259:6702] TIC Read Status [6:0x0]: 1:57
  2018-04-14 20:50:13.674595+1200 MPM[259:6702] TIC Read Status [6:0x0]: 1:57
  2018-04-14 20:50:21.735145+1200 MPM[259:6736] TIC Read Status [9:0x0]: 1:57
  2018-04-14 20:50:21.735254+1200 MPM[259:6736] TIC Read Status [9:0x0]: 1:57
  2018-04-14 20:50:22.448789+1200 MPM[259:6335] [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction
  2018-04-14 20:50:22.449513+1200 MPM[259:6335] [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction
  2018-04-14 20:50:23.017697+1200 MPM[259:6493] TIC Read Status [10:0x0]: 1:57
  2018-04-14 20:50:23.017805+1200 MPM[259:6493] TIC Read Status [10:0x0]: 1:57
  2018-04-14 20:50:28.214627+1200 MPM[259:6491] TIC Read Status [11:0x0]: 1:57
  2018-04-14 20:50:28.214717+1200 MPM[259:6491] TIC Read Status [11:0x0]: 1:57
  2018-04-14 20:50:28.718297+1200 MPM[259:6335] [Snapshotting] Snapshotting a view (0x13f01c400, UIKeyboardImpl) that is not in a visible window requires afterScreenUpdates:YES.
  2018-04-14 20:50:33.931411+1200 MPM[259:6335] +[CATransaction synchronize] called within transaction
  2018-04-14 20:50:33.931806+1200 MPM[259:6335] +[CATransaction synchronize] called within transaction
  2018-04-14 20:50:33.932168+1200 MPM[259:6335] +[CATransaction synchronize] called within transaction
  2018-04-14 20:50:33.932495+1200 MPM[259:6335] +[CATransaction synchronize] called within transaction
  2018-04-14 20:50:33.932496+1200 MPM[259:6521] TIC Read Status [8:0x1cc16f180]: 1:57
  2018-04-14 20:50:33.932609+1200 MPM[259:6521] TIC Read Status [8:0x1cc16f180]: 1:57
  (lldb) 
  </code></pre>
  
  <p>After Xcode gave me that output I believe its something to do with the way I am attempting to load the view of the view controller?</p>
  
  <pre><code> func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -&gt; Bool {
      //Configure Firebase
      FirebaseApp.configure()
      FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
      //Create window and assign root view controller, since not using storyboard
      window = UIWindow()
      let vc = MainTabBarController()
      window?.rootViewController = vc
      window?.makeKeyAndVisible()
      return true
  }
  </code></pre>
  
  <p>After following the advice of adding breakpoints I was able to find out that the app never makes it past line 171 below:</p>
  
  <p><a href="https://i.stack.imgur.com/feLEg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/feLEg.png" alt="code with breakpoints where error ocurrs"></a></p>
  
  <p>Cheers</p>