Voltar ao ranking

Pure Swift iOS download framework with background downloads, relaunch recovery, resumable transfers, and task management.

cocoapodsxcodeswiftiosnetworkbackground-downloaddownload-managerfile-downloadresumable-downloadurlsession
Crescimento de estrelas
Estrelas
2.9k
Forks
415
Crescimento semanal
Issues
2
1k2k
mar. de 2018dez. de 2020out. de 2023jul. de 2026
README
Tiercel logo

English | 简体中文

CocoaPods Version iOS 12.0+ Swift Package Manager Platforms Swift Versions License

Tiercel is a production-oriented iOS download framework in pure Swift for background downloads, relaunch recovery, resumable transfers, and URLSession-based task orchestration.

Indexed on Swift Package Index and featured in awesome-swift and awesome-ios.

If Tiercel helps your team ship reliable downloads, consider starring the repository.

Why Teams Pick Tiercel

  • Background downloads that stay close to native URLSession behavior.
  • Relaunch recovery through persisted task metadata and resume data.
  • Fine-grained control for start, suspend, cancel, remove, and batch operations.
  • Multiple SessionManager instances so different download domains stay isolated.
  • Network policy knobs for cellular, constrained, and expensive connections.
  • Built-in speed, remaining-time, and file-validation callbacks.
  • Thread-safe internal state designed for long-running download flows.

Choose Tiercel If

  • You need downloads to recover after the app relaunches.
  • You manage more than one download queue, domain, or product surface.
  • You want batch downloads and operational visibility instead of ad hoc tasks.
  • You prefer a higher-level API than raw URLSessionDownloadTask, while still using Apple's native stack underneath.
  • You need a download layer that can be evaluated quickly through a real demo app.

At A Glance

What you need Raw URLSession only Tiercel
Background downloads Base primitives Higher-level manager and task model
Relaunch recovery App-specific persistence work Built-in persisted task metadata and resume data
Batch operations Manual orchestration Multi-download helpers and manager-level controls
Download domain isolation Custom architecture Multiple isolated SessionManager instances
Progress and validation hooks Hand-rolled callbacks Built-in progress, speed, ETA, and validation APIs

Installation

CocoaPods

platform :ios, '12.0'
use_frameworks!

target 'YourTargetName' do
  pod 'Tiercel'
end

Then run:

pod install

Swift Package Manager

In Xcode, choose File > Add Package Dependencies... and use:

https://github.com/Danie1s/Tiercel.git

Manual Integration

Drag the Sources directory into your project and make sure the files are included in the desired target.

Quick Start

import Tiercel

var configuration = SessionConfiguration()
configuration.allowsCellularAccess = true
configuration.maxConcurrentTasksLimit = 3

let manager = SessionManager("downloads", configuration: configuration)

let task = manager.download("https://example.com/video.mp4")

task?.progress(onMainQueue: true) { task in
    print("progress:", task.progress.fractionCompleted)
}.success { task in
    print("saved to:", task.filePath)
}.failure { _ in
    print("download failed")
}

You can control downloads by URL or by task instance:

let url = "https://example.com/video.mp4"

manager.start(url)
manager.suspend(url)
manager.cancel(url)
manager.remove(url, completely: false)

if let task = task {
    manager.start(task)
    manager.suspend(task)
    manager.cancel(task)
    manager.remove(task, completely: false)
}

Tiercel also supports batch creation and start:

let urls = [
    "https://example.com/episode-1.mp4",
    "https://example.com/episode-2.mp4"
]

let tasks = manager.multiDownload(urls)
print(tasks.count)

Background Downloads And Relaunch Recovery

Tiercel persists task state and resume data to disk, so downloads can be restored after the app relaunches. If the user force-quits the app, iOS stops background execution until the next launch; once the app is opened again, Tiercel can recover eligible downloads and continue from stored state.

To support native background session callbacks, wire the completion handler from AppDelegate to the matching SessionManager:

let downloadManagers = [managerA, managerB]

func application(_ application: UIApplication,
                 handleEventsForBackgroundURLSession identifier: String,
                 completionHandler: @escaping () -> Void) {
    for manager in downloadManagers where manager.identifier == identifier {
        manager.completionHandler = completionHandler
        break
    }
}

Network Policy And File Validation

SessionConfiguration lets you tune network behavior for different products or environments:

var configuration = SessionConfiguration()
configuration.maxConcurrentTasksLimit = 3
configuration.allowsCellularAccess = true
configuration.allowsConstrainedNetworkAccess = true
configuration.allowsExpensiveNetworkAccess = true

let manager = SessionManager("downloads", configuration: configuration)

You can also validate downloaded files when integrity matters:

task?.validateFile(code: "9e2a3650530b563da297c9246acaad5c",
                   type: .md5,
                   onMainQueue: true) { task in
    if task.validation == .correct {
        print("file is valid")
    } else {
        print("file is invalid")
    }
}

Compatibility

  • Minimum platform: iOS 12.0+
  • Language baseline: Swift 5.0+
  • Distribution: CocoaPods, Swift Package Manager, and manual source integration

Demo

Open Demo/Tiercel-Demo.xcodeproj to explore:

  • Single-file downloads
  • Batch downloads
  • Multiple isolated download managers
  • Background session event handling
  • Validation and progress callbacks

Tiercel demo 1 Tiercel demo 2

Repository Layout

  • Sources/General: core session, task, cache, and status-management logic
  • Sources/Extensions: lightweight helpers used across the framework
  • Sources/Utility: checksum and resume-data utilities
  • Demo: sample iOS app for evaluation and manual testing

License

Tiercel is available under the MIT license. See LICENSE for details.

Repositórios relacionados
dkhamsing/open-source-ios-apps

:iphone: Collaborative List of Open-Source iOS Apps

Creative Commons Zero v1.0 Universaliosswift
51.3k6k
Alamofire/Alamofire

Elegant HTTP Networking in Swift

SwiftMIT Licensenetworkingurlsession
42.4k7.7k
SDWebImage/SDWebImage

Asynchronous image downloader with cache support as a UIImageView category

Objective-CMIT Licensemacosios
sdwebimage.github.io
25.6k6k
SwiftyJSON/SwiftyJSON

The better way to deal with JSON data in Swift.

SwiftMIT Licenseswiftyjsonjson
22.9k3.4k
SnapKit/SnapKit

A Swift Autolayout DSL for iOS & OS X

SwiftMIT Licenseautoautolayout
snapkit.github.io/SnapKit/
20.3k2k
SwifterSwift/SwifterSwift

A handy collection of more than 500 native Swift extensions to boost your productivity.

SwiftMIT Licenseswiftxcode
swifterswift.com
15.1k1.7k
CocoaPods/CocoaPods

The Cocoa Dependency Manager.

RubyRubyGemsOtheriosdependency-manager
cocoapods.org
14.8k2.7k
CocoaLumberjack/CocoaLumberjack

A fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS, watchOS and visionOS

Objective-CBSD 3-Clause "New" or "Revised" Licensemacosios
cocoalumberjack.github.io
13.3k2.3k
SVProgressHUD/SVProgressHUD

A clean and lightweight progress HUD for your iOS and tvOS app.

Objective-CMIT Licenseobjective-chud
github.com/SVProgressHUD/SVProgressHUD
12.5k2.7k
xmartlabs/Eureka

Elegant iOS form builder in Swift

SwiftMIT Licenseiosforms
eurekacommunity.github.io
11.8k1.3k
ninjaprox/NVActivityIndicatorView

A collection of awesome loading animations

SwiftMIT Licenseswiftanimation
10.7k1.2k
WenchaoD/FSCalendar

A fully customizable iOS calendar library, compatible with Objective-C and Swift

Objective-CMIT Licenseswiftobjective-c
10.6k1.9k