RORK LABJP
BUILD — Rork Max runs real Macs in the cloud loaded with Xcode and the iOS SDK, writing SwiftUI, compiling, reading the errors and building again. That loop, not the code generation, is what lifts the outputNATIVE — What comes out is pure Swift and SwiftUI, not React Native. Reaching AR, Metal graphics and widgets that React Native cannot touch is the real gap between this and other buildersPLATFORMS — Coverage spans iPhone, iPad, Apple Watch, Apple TV and Vision Pro, plus iMessage. Worth a look if you want to start from a watch app or an extension rather than a phone screenCOMPANION — The Rork Companion app lets you check a generated build on a real iPhone without a paid Apple Developer account, lowering the bar for trying a first project end to endPRICING — Free to start, paid plans from $25 a month, and Rork Max on the $200 Max plan. Worth working out up front how many projects it takes to earn that backDEADLINE — From August 31, 2026, Google Play requires target API level 36 or higher for new apps and updates alike. Ten days out, and the targetSdkVersion of what you generate is yours to verifyBUILD — Rork Max runs real Macs in the cloud loaded with Xcode and the iOS SDK, writing SwiftUI, compiling, reading the errors and building again. That loop, not the code generation, is what lifts the outputNATIVE — What comes out is pure Swift and SwiftUI, not React Native. Reaching AR, Metal graphics and widgets that React Native cannot touch is the real gap between this and other buildersPLATFORMS — Coverage spans iPhone, iPad, Apple Watch, Apple TV and Vision Pro, plus iMessage. Worth a look if you want to start from a watch app or an extension rather than a phone screenCOMPANION — The Rork Companion app lets you check a generated build on a real iPhone without a paid Apple Developer account, lowering the bar for trying a first project end to endPRICING — Free to start, paid plans from $25 a month, and Rork Max on the $200 Max plan. Worth working out up front how many projects it takes to earn that backDEADLINE — From August 31, 2026, Google Play requires target API level 36 or higher for new apps and updates alike. Ten days out, and the targetSdkVersion of what you generate is yours to verify
Articles/App Dev
App Dev/2026-07-03Advanced

Keeping Downloads Alive After Your Rork Max App Is Killed: Background URLSession Design and Relaunch Handling

How to design downloads in a Rork Max native Swift app so transfers continue in the OS daemon even after the app is suspended or terminated. Covers relaunch wiring, resumeData recovery, and measured isDiscretionary behavior with working code.

Rork Max233URLSessionBackground TransferSwift48iOS110Downloads

Premium Article

When I started shipping high-resolution image packs in one of my wallpaper apps, a pattern of reviews appeared: "downloads stop halfway, every time." Digging in, the cause was mundane. Users tapped download, went back to the home screen, and roughly thirty seconds later iOS suspended the app — taking the transfer down with it. As an indie developer staring at server logs, all I could see was "client closed connection." It took me days to trace it back to the app's own lifecycle.

The fix was architectural, not incremental. A standard URLSession lives and dies with your process. If you want a transfer to survive suspension — or outright termination — you have to hand the transfer itself to the operating system through a background session.

Because Rork Max generates native Swift, this machinery is fully available to you. But if you write against it with the same habits you use for ordinary sessions, you will hit runtime crashes and silently vanishing files. What follows is the setup I actually run for delivering add-on content packs, walking through each design decision in order.

The Transfer Belongs to nsurlsessiond, Not Your App

The essence of a background session is that the transfer's execution moves out of your process. The real worker is a system daemon called nsurlsessiond. Your app can be suspended, or jettisoned under memory pressure, and the bytes keep flowing.

Here is how the two session types differ in practice.

AspectStandard sessionBackground session
Where the transfer runsInside your app's processnsurlsessiond (out of process)
After the app is suspendedTransfer is cut offTransfer continues
After the app is terminatedTransfer is goneTransfer continues; the app is relaunched on completion
Completion-handler APIsAvailableUnavailable (runtime exception)
DelegateOptionalRequired
dataTaskAvailableNot supported in practice (download/upload tasks only)

The last two rows are where most people trip first. Closure-based calls like session.downloadTask(with: url) { location, response, error in ... } throw the moment you invoke them on a background configuration. Since the task may finish while your app does not exist, there is nothing to hold that closure — every result must arrive through a delegate.

Creating the Session and Its Three Constraints

Start with a singleton manager. Creating multiple sessions with the same identifier leads to undefined behavior, so keep construction in exactly one place.

// BackgroundDownloadManager.swift
import Foundation
 
final class BackgroundDownloadManager: NSObject {
    static let shared = BackgroundDownloadManager()
    static let sessionIdentifier = "com.example.app.asset-downloads"
 
    /// Handed to us by the AppDelegate when the app is relaunched
    var backgroundCompletionHandler: (() -> Void)?
 
    private lazy var session: URLSession = {
        let config = URLSessionConfiguration.background(
            withIdentifier: Self.sessionIdentifier)
        config.sessionSendsLaunchEvents = true  // wake the app after termination
        config.isDiscretionary = false          // run immediately (more below)
        config.allowsCellularAccess = true
        return URLSession(configuration: config,
                          delegate: self,
                          delegateQueue: nil)
    }()
 
    func download(_ url: URL) {
        let task = session.downloadTask(with: url)
        // Telling the OS the expected size stabilizes its scheduling
        task.countOfBytesClientExpectsToReceive = 20_000_000
        task.resume()
    }
}

What this code buys you is the decoupling of a started download from your app's lifecycle. Three constraints to internalize:

First, the delegate can only be supplied at initialization. There is no API to swap it later, which is why passing the singleton's self is the natural shape.

Second, without sessionSendsLaunchEvents = true, the system will not relaunch your app when a transfer finishes after termination. It defaults to true, but I write it out to make the intent explicit.

Third, identifiers must be unique within your app. If you want separate sessions per feature, give each its own identifier and its own independent delegate.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Walk away with a working Swift download foundation where transfers keep running in the OS daemon even after your app is suspended or killed
Understand the correct wiring for handleEventsForBackgroundURLSession in a SwiftUI app, including when to hold and when to call the completion handler
Avoid the production traps in advance: resumeData recovery, synchronous temp-file moves, and the measured real-world behavior of isDiscretionary
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

App Dev2026-07-03
Making Your Rork Max App Resilient to Dropped and Restored Connections: Offline Detection and Retry with NWPathMonitor
Build networking that survives a lost signal in your Rork Max native Swift app with NWPathMonitor. Detect offline states, respect Low Data Mode and cellular, and auto-resend queued work on reconnect — all with working Swift code.
App Dev2026-06-16
Staging Wallpaper Packs Before the First Launch: Where Rork Max and Background Assets Fit
Content-heavy apps tend to greet new users with an empty grid. Background Assets downloads content out-of-band, ahead of the first launch. Here is how I implement it in Rork Max's native Swift, a domain Rork (Expo) cannot reach easily, plus how I decide when it is worth it.
App Dev2026-06-16
Building a WeatherKit App with Rork Max — The Auth and Attribution Pitfalls
When you add WeatherKit to a native Swift app generated by Rork Max, the first walls are authentication and attribution. Here is the workflow I confirmed: token handling, rate limits, and the mandatory data-source display.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →