简体   繁体   中英

Application crashes when not running from Xcode but works fine when run from Xcode

I have this strange issue. When I run application from Xcode (even on device), it works fine without any crash. But as and when I run it on device without Xcode, it crashes when I navigate back from one of the viewController. I am not able to get the reason for crash as I can't use log. Has someone experienced this before?

I recently experienced this after adding an MKMapView to the Storyboard. It ran perfectly when the device was attached to Xcode, but crashed when running without being connected to the computer.

The mistake I made was not checking the Embedded Frameworks.. the app was trying to load the MKMapView without having the MapKit framework imported.

The best way to diagnose this though, is to check your crash logs on the device you're using and you'll get a better understanding on what caused it

I am not able to get the reason for crash as I can't use log.

Open the Xcode organiser window, there's a section called "Device Logs" for each of your devices. A crash log is produced each time an application crashes. If you look at the console, you will also see anything you've logged with NSLog .

A solution to see what happens could be to download this app and see the logs/warnings. Or just open the Organizer and see the console of your device.

Sometimes "Segmentation fault" occurs when any of your UI element or any other instance gets autoreleased. You can enable zombies to look out for your allocation/deallocation. You can also use "Instruments" ('Allocation' template) tool to see the allocation/deallocation/retain/release of objects and it will give you the backtrace at the point of allocation.
There is a fair chance that any of your UI element instance is not getting retained.
It would have been more helpful if you can post the device logs too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM