I am currently working on code to log a user's behavior in the app and to report crashes and the sequence leading up to them. I have one big problem, I do not know how to make my app detect if it has crashed. Does anybody know how to do this in swift? Your help would be much appreciated!
I don't think there is currently a way to do this. When your app crashes it ceases to function and all processes stop. Usually any crash and diagnostic data is sent via the user settings panel.
Edit: There is an helpful post here: https://stackoverflow.com/a/8242215/4891259
Hope that helps.
Related
Our apps are live on the app store.
I wish to recognise crashes of out of memory that some users are getting.
I understand there is no way to 100% recognise an out of memory crash.
Is there any way to recognise these crashes(with a pretty large probability) by doing some logic in the applicationDidReceiveMemoryWarning? (I am not talking about finding it in xcode during development time, i am talking about code that will recognise the out of memory crash from actual users and will log something to file)
While I was looking for any service or library that give me OOM tracking, I could only find this article from Facebook engineering:
https://code.facebook.com/posts/1146930688654547/reducing-fooms-in-the-facebook-ios-app/
The idea is to deduce the reason why the app needs to be launch, checking different aspects (like if the app was at background, if there is an app/OS update,...).
Discarding all the other possible reason that can force the previous app exit, you can know if the reason is a background out of memory or a foreground out of memory.
It would be nice to have a library that implements the Facebook article procedure. But nowadays I couldn't find any, probably there is some reason that make this difficult or may be impossible to add it as an sdk.
If anyone knows any service, please share it with everyone with a comment or a new answer.
Edit:
I have discovered this github (https://github.com/jflinter/JRFMemoryNoodler) with an implementation of the Facebook post procedure. I haven't tried yet, but we will deploy it in our apps to try it.
Look out for the applicationWillTerminate message in your app delegate. This is called if you app is terminated by the system (due to e.g. low memory), but not if the user leaves the app in the usual way by pressing the home key. Note: if your app is in the background and memory runs out, your app gets killed without any messages being sent to it.
YMMV, especially with older versions of iOS, and it's worth researching to ensure that the above is accurate.
The images at this blog post are quite informative (although slightly dated).
For more info, see How to know whether app is terminated by user or iOS (after 10min background)
Firstly Analyse your application by clicking on the Product at the top menu bar of your Xcode and click on Analyse section it will show you the number of leaks on in the application and can take you to the place where leaks occurred. This is how you can find the memory leak and rectify it.
Secondly it above does not worked then see to the view controller where crash occurred and check whether you have left any object to release.
Hope this might help you to resolve your problem.
My latest iPhone/iPad application works fine on the simulator.
On the iPad, it works fine for sometime but then crashes. The console shows that it is dues to a segmentation fault that I am assuming is happening due to a message being sent to a zombie. Since this is happening only on the actual device it will not be possible for me to use the NSZombieEnabled/Instruments.
What debug options do I have in the absence of instruments/zombie-detection on actual device?
Code Review - Completed, did not find anything obvious
Put comments and follow through the narrow down on zombies - In progress
What else can I do? any suggestion will be appreciated.
I did go through the past questions but did not get many options to look at....I apologize in advance if this question is already answered but would appreciate if you could share the link or provide guidance.
R.S.
Look at this post to see how to turn on Zombie objects.
https://stackoverflow.com/a/4917557/613156
You can turn it on through the diagnostics panel and it will run on your device.
I wana close all the application runing in the background by single button click. Is this possible? I read all the related post.They all describe about the single application but i want to close all the running apps.I know that apple doesn't allow this.But Is there any private api for this? Please help me.Help would be appricieted. Thank you very much.
I don't think So we can do anything like this as You want to do that from some app which is having its own Address Space i.e. sandBox. Means Every App is having its own Address Space which Other App Cannot Access it, as it will result in Crash.
So, sorry to say but we Cannot up to my Knowledge... :)
I don't think it is possible but Even if you do something like this your app is for sure be rejected from uploading on app store, this will be a virus for iphone,
There is no need to stop all running apps by any means, and there is no way to do this programmatically other than jail breaking your device and hacking something together.
But in the end it makes no sense at all, see: http://speirs.org/blog/2012/1/2/misconceptions-about-ios-multitasking.html
I want to implement something like what four square do when the application crashes it sends out the crash report to their developers. But I really do not know how this is achieved. Can someone please let me know how this works and the components needed to implement something like this.
I guess the iPhone stores the crash report internally so you need to access it and I read something about a dSYM file as well? I this all I need? How can you get access to the crash file to email it out?
Thanks a lot for any help you can give.
EDIT:: So flurry has been mentioned, is there anything else anyone can recommend to achieve this?
It would be much simpler and easier if you use some tools such as Flurry (flurry.com). They offers built-in crash report. For example, Flurry can catch uncaught exceptions and log it, and since it sends the log to their server, you can view it online just like the normal event analytics.
You can also check out Apsalar, which is another pretty robust iOS / Android analytics package. It used to be pretty expensive but is now free. It can be configured to do crash reports as well.
Is it possible to invoke an app automatically when it encounters a crash in iPhone/iPad? If so, any pointers will certainly help. Thanks!
That's not possible so design your app NOT to crash instead :)
I've not tried this, but there's a reasonable chance you can run code when the app crashes by installing signal handlers in the standard C way for SIGABRT, SIGSEGV, etc.
However I have no idea how you'd make your app relaunch.
As others have said, the best approach is to stop your app crashing - that's what everyone else does.
Its not possible.