In an Xcode project, how can I write any Swift codes that crashes the Application on startup once itβs launched/run on the simulator or device?
Asked
Active
Viewed 114 times
-2
-
1What does crushing an application mean? β Jan 13 '22 at 05:30
-
I suppose the author of the question means "to crash". β lazarevzubov Jan 13 '22 at 05:31
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. β Community Jan 22 '22 at 13:12
1 Answers
1
You can follow app lifecycle events in your UIApplicationDelegate
. For example application(_:didFinishLaunchingWithOptions:))
is called, when the app started and a little time before it's visible. You can put the crashing code there.
There are a few ways to crash the app. One of them is to call fatalError()
.

lazarevzubov
- 1,767
- 2
- 14
- 24