Hello, I know that in the past it was explicitly forbidden to programmatically end the app, but I cannot find the reference on the current guidelines. The only thing I found was this: https://developer.apple.com/library/archive/qa/qa1561/_index.html but this site has a box on top saying that is not being updated anymore.
What is the current policy about this? Is it allowed now?
Thank you! :)
Hello, I know that in the past it was explicitly forbidden to programmatically end the app,
That's actually not true and never has been. The actual issue here was, and still is, what's mentioned in QA1561*:
but I cannot find the reference on the current guidelines. The only thing I found was this: https://developer.apple.com/library/archive/qa/qa1561/_index.html but this site has a box on top saying that is not being updated anymore.
As it says:
"Applications calling exit will appear to the user to have crashed..."
...and App Review will reject any app that crash or appears to crash.
What is the current policy about this? Is it allowed now?
The current policy is exactly, namely that your app should not "crash". In general, that means apps should not call exit, particularly since calling it in the foreground is visually equivalent to crashing.
As a side note on that point, notice the initial release date of QA1561:
2008-08-27
New document that discusses best practices for terminating an iOS application in code.
That's approximately 1 month after iOS 2 shipped and 2 years before we introduced background execution or app suspension. In other words, when QA1561 the only time an app COULD have called exit was when it was in the foreground.
All of that leads to here:
Is it allowed now?
The general answer is that most apps shouldn't be calling it, however, there are exceptional/unusual background situations where it can be useful. For example, I've occasionally suggested it as the final option for "foreground only" apps which are having problems with data protection, as terminating your self in the background is "safer" than leaving your app "stuck" without access to the data it needs to operate properly.
So, why do you want to call it?
*On a purely personal note, I think QA1561 was the first QA I ever wrote.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware