Logging thread stacktrace when stuck in ios - ios

My app got stuck for 15sec and then released, during this period complete UI got frozen and user can't click on anything. Its a production app and not reproducible in debug mode.
Is there any way to log the thread stack trace when app hangs (similar to ANR for Android)?

You can try to put exception breakpoint to you project / workspace.
Go to Breakpoint tab on left pane and hit the plus(+) symbol on left side.
And then just add exception breakpoint.
Then you can also edit the breakpoint to have it only for Objc exceptions.
You can reveal the reason the app crashes this way but it also can be caused by memory exception etc.
If you won't find an answer this way, you can try to use Instruments. Here is a good tut how to use it. `Ray Wenderlich - Instruments tutorial

Connect your device to your computer. Open Xcode. On the tab bar there is a menu named "Window" select "Devices" option from it. On the left column, you will see your devices. Select your phone. On the same screen there will be a log console which outputs devices logs and user logs (written using NSLog)
To write your NSLog logs into a file you should write a custom method to do that. For this you can see this question there is a few ways to implement it. It'll be useful for you.

Related

Run Xcode Instruments on device with a ios keyboard extension

I'm developing a custom keyboard but it's very slow and sometimes it's crashing.
Because I'm not sure where it comes from, I'd like to Time Profiler with Instruments. But when I select MyIphone > Keyboard Extension (target), I get:
Target failed to run
or
Waiting for x.x.x.Keyboard
Please take appropriate action to initiate the launch of 'x.x.x.Keyboard.'
Is it even possible to use Instruments with an app extension? If yes, how should I proceed?
I can't use Instruments to analyze my keyboard before, however my method might be helpful to you.
Run the project on your iPhone.
Xcode the left column, the seventh button 'Show the Debug navigator', select the 'Memory' column.
In the right 'Memory Report', select 'Profile in Instruments' in the upper right corner. Instruments will open.
I used this method to enter the Instruments tool to analyze the memory. I noticed that the software name displayed on the Instruments tool was followed by a number, like com.xxx.xxx.keyboard (4489).
Accessing Instruments directly from Xcode->Product->Profile does not work properly. This may be the key.
Hope this helps you.

How to capture crashes if the app crashes on launch

I currently have an issue with my app where it's crashing on launch in some cases for some users in the field, but not in-house. In this case, the whole app shuts down before Crashlytics gets a chance to submit its crash report. How do I avoid this? The Crashlytics delegate protocol doesn't seem to support anything useful in this case - I tried turning off the asynchronous submission functionality, but it did not help. What's the best solution to capture crashes that happen immediately on start-up?
Edit: I am talking about capturing crashes from users in the field, not from my own device.
XCode->(Window menu -> Organizer, or Cmd-Shift-2.) Find your device in the left sidebar, then select “device logs”.
A tool for detecting and repairting continuous launch crash of iOS App
https://github.com/liuslevis/GYBootingProtection

Is there a way to stop an app from closing if it stalls on splash screen?

I've been testing an app for iOS in Xamarin Studio, however whenever I reach a breakpoint or an exception is thrown and I stay there for a few seconds without pushing the continue execution button, the debugging session will close as the app will close on my device. This is due to the process mentioned here, as it is occurring during the splash screen, and if the app pauses too long there, it will close the app because it failed to scene-create. I was wondering if it is possible to disable this when debugging with breakpoints, because I would like to look at the data flow through variables and such.
As matt guessed, it is a Xamarin issue. The response to my inquiry to Xamarin was this,
Xamarin does not currently use a native debugger, thus watchdog is not
disabled. They are looking into alternatives, but for now a potential
workaround is to not do anything until you've returned from the
FinishedLaunching method (i.e. start your launch code in a timer event
for instance), and debug that instead.
Update: the status on this bug is "fixed for the next major release." as of 12/29/15

Way to see crash logs for an iOS app outside of an Xcode debugging session?

I have an app where the user needs to login before using it .
to enhance the user experience , the user needs only to login at the first time and each other time the app will not show the login screen but it will show the app [ I am using user default to store his id ]
now I have achieved this but I ran into a bug and the app crashes when I open it after a succeeded login ..
The problem is :
to mimic the scenario where I open the app without the need to login , I had to stop the app [ which means there will be no debugging session ] and then reopen the app ..
What I am asking for :
is there a way to see what causes the bug knowing that I am not running the app in a debugging session ?
Thanks in advance
Can you run your app on a device? If so, you might be able to get the crash data you need from the Devices window, from Xcode.
Xcode -> Window -> Devices.
Select your device, then select View Device Logs.
Here's Apple's page on the subject.
For running in the simulator, you may be able to get the crash data you need from the Console (I've just tried this and seen at least one crash log from my current development).
Here is Apple's page on Testing with the Simulator. From the menu on the left, check out Viewing Crash Logs. Extract from that page...
To view a crash log
Open Console by going to Applications/Utilities/Console in the Finder.
Look for the line in Console that reads “Saved Crash Report for.”
Expand this item using the arrow at the left.
Click Open Report.
You can maybe check: https://try.crashlytics.com/
It's part of the twitter Fabric framework now quite easy to use, and provides good information
Use Hockey app for getting the info regarding the crash logs:
Here is the link to setup the Hockey app in iOS:
http://support.hockeyapp.net/kb/client-integration-ios-mac-os-x/hockeyapp-for-ios
check plcrashreporter : https://code.google.com/p/plcrashreporter/downloads/list
http://plcrashreporter.googlecode.com/svn/tags/plcrashreporter-1.1-beta1/Documentation/API/functions.html
it's very easy to use and
If your application crashes, a crash report will be written. When the application is next run, you may check for a pending crash report, and submit the report to your own HTTP server, send an e-mail, or even introspect the report locally

NSLog not working when "wait for executable to be launched" is set

I am just exploring debugging as per the subject line. I am noting that while this works easily enough, the NSLog's are not outputting, but breaks do get hit. This is not helping ;) .. I don't see any obvious options in the edit scheme window.
This is to test pushes, but firstly i am just manually firing up the app to ensure the process works (with waiting for the app to manually start etc)..
Thanks for any tips..
If you let the process start normally, then the logs will be hooked up to ASL already. The debugger doesn't have a good way to reroute this connection after the fact. You will have to look in the Device Console for the logs. In Xcode 6, select Windows->Devices, then there's a little disclosure widget at the bottom of the content window that will reveal the Device console.
Use breakpoints to log whatever You want
Right click on breakpoint -> Edit Breakpoint
Check "Automatically continue after evaluating options" to make sure app won't stop at break
Add Action(s) to log info You need

Resources