How can i crash app with some log in swift? [duplicate] - ios

This question already has answers here:
Easiest way to force a crash in Swift
(6 answers)
Closed 3 years ago.
I want to crash my app forcefully but also want that app first print crash log on debuging window and than terminate app.
It's for testing purpose to test app to fetch crash log.
Thank you.

Simple :
var arr = [Int]()
arr.remove(at: 1)

Related

iOS - Start a function if app is closed [duplicate]

This question already has answers here:
Perform background tasks when app is terminated
(3 answers)
Detect iOS app entering background
(7 answers)
Closed 5 years ago.
I wonder if it's possible with swift, start a function at a certain time, especially if the app is closed.
I tried a bit around but did not find anything useful.
I hope you can help me.
Thanks
You can try to override functions like
applicationDidEnterBackground
applicationWillTerminate
applicationDidBecomeActive

Swift iOS 9+ before app closes/before app opens [duplicate]

This question already has answers here:
Save the current status when quit, auto-reload when re-open the app
(2 answers)
Closed 6 years ago.
I want, using Swift in iOS, to capture a variable before the app closes from a subview and place it in storage, and prior to the app gets too far along on re-open restore this variable.
I know how to get and set, I just am hoping to stumble across the events that trigger before the app closes and shortly after it launchers.
You should do this in the AppDelegate.swift file.

how to make iPhone app crash after launch? [duplicate]

This question already has answers here:
What's a reliable way to make an iOS app crash?
(18 answers)
Closed 8 years ago.
What is the code on Xcode and where do I put it to make an iOS app crash?
I want to make my app launch a url and then crash. Is there any way to do this?
Thanks
This sounds like a terrible idea, but if you insist you can just call a method that doesn't exist to force a crash, e.g.
[self performSelector:#selector(doesntExist:)];
Or you can close the App like this:
exit(0);
But you really shouldn't do this, neither of these methods are acceptable for the App Store (or anything for that matter!)
If you just want to crash (in order to see how your app recovers from a crash), simply do something stupid like [nameOfArray objectAtIndex:100000000];

Is there a way to read the crash log of an app at runtime [duplicate]

This question already has answers here:
iOS crash log catch, debug info.. Catch and send via email to the Dev team
(9 answers)
Closed 8 years ago.
Is there a way to read the crash log of an app at runtime?
What I mean is this, have some method running at the first beginning of an app that will monitor if the app crashed last time. If so, it will read the crash log, attach it to an email and send it to me.
I know apple has that functionality on iTC but it just shows crashes for a large amount of users and I want to know about all crashes that may be happening without my knowledge. You know, users don't give a crap and will never warn you.
Is this possible?
You could try using the TestFlight SDK. If the app crashes a crash report can be read on the website.
https://testflightapp.com/sdk

Log method entry and exit Objective C [duplicate]

This question already has answers here:
How to log all methods used in iOS app
(8 answers)
Closed 10 years ago.
I have used NSObjCMessageLoggingEnabled for logging the method entry and exit at run time for an application. THe logs has been saved in /tmp/msgSends-pid. Whre pid is process ID.
I want to save same logs while running an app on the iPhone device instead of running app on emulator using Xcode.
Please let me know if you require more details to help me out.
NSObjCMessageLoggingEnabled appears in Apple's technical note about Mac OS X debugging magic, but not the one about iOS debugging magic. It appears that it is unavailable on iOS.
Apparently, you can log Objective-C method entries and exits using a DTrace probe in Instruments.

Resources