iOS 12 terminates apps in the background for no reason : <p>Starting from iOS 12 the CLLocationManager doesn't run endless anymore in the background. The app get's terminated without a crashlog at random times. This was working fine before iOS 12.</p>

<p>To demonstrate this problem I've created an sample app <a href="https://github.com/flitsmeister/ios-cllocationmanager-background" rel="noreferrer">here</a></p>

<p>The demo app just launches an CLLocationManager and keep this running in the background. While running on the background we keep track of it by logging it. The problem is that the app get terminated by iOS. The demo app is created to demonstrate this problem.</p>

<p><strong>Steps to reproduce</strong></p>

<ol>
<li>Run the app on the device </li>
<li>Grand access to locationmanager</li>
<li>Put the app to the background</li>
<li>Wait for 1-48hours </li>
</ol>

<p><strong>Result:</strong></p>

<ol start="5">
<li>The app is terminated</li>
</ol>

<p>App is terminated without any reason after random time.</p>

<p><strong>Expected result:</strong></p>

<ol start="5">
<li>The app is still running.</li>
</ol>

<p><strong>How it should work</strong></p>

<p><em>This is confirmed by an Apple engineer:</em></p>

<p>Once the CLLocationManager updates are started in the foreground and you did all the work to have it running in the background, the location updates should run endless in the background until:</p>

<ul>
<li>app is force quit</li>
<li>device is rebooted</li>
<li>app stops location updates</li>
<li>app releases the CLLocationManager object</li>
<li>app crashes</li>
<li>iOS terminates the app due to memory shortage,</li>
<li>the locationManager object is released, overreleased, or overwritten. You should make sure that your view controller is not being instantiated, which then resets the locationController class. If that happens when the app is in the background, you will restart updates, which will cause the app to be eventually suspended. You should make sure the locationController is a singleton.</li>
<li>app is crashing. Check to see if there are crash logs on the device you are testing</li>
<li>iOS is terminating the app due to memory shortage. In this case, you will find JetsamEvent logs on the device that shows your app being terminated. You can check the timestamps and locate the one that is around the time your app stopped working.</li>
</ul>
