All Projects → Danie1s → Tiercel

Danie1s / Tiercel

Licence: mit
简单易用、功能丰富的纯 Swift 下载框架

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Tiercel

Microfeatures Example
📦📱 Example of iOS app built using the uFeatures architecture
Stars: ✭ 112 (-95%)
Mutual labels:  xcode, cocoapods
Cloudkitgdpr
Framework for allowing users to manage data stored in iCloud
Stars: ✭ 126 (-94.38%)
Mutual labels:  xcode, cocoapods
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-94.69%)
Mutual labels:  xcode, cocoapods
Materialactivityindicator
Material Activity Indicator
Stars: ✭ 109 (-95.14%)
Mutual labels:  xcode, cocoapods
Nearbyweather
NearbyWeather is an open source weather app for iOS, which uses the OpenWeatherMap API. With this project developers are invited to learn advanced iOS concepts, as well as to contribute further advancements. Fork this repo to get started.
Stars: ✭ 146 (-93.49%)
Mutual labels:  xcode, cocoapods
Device
Light weight tool for detecting the current device and screen size written in swift.
Stars: ✭ 1,503 (-32.93%)
Mutual labels:  xcode, cocoapods
Luexpandabletableview
A subclass of UITableView with expandable and collapsible sections
Stars: ✭ 125 (-94.42%)
Mutual labels:  xcode, cocoapods
Everlayout
Reusable, downloadable, up-datable iOS layouts
Stars: ✭ 103 (-95.4%)
Mutual labels:  xcode, cocoapods
Donut
Donut is a library for arranging views circularly like a donut.
Stars: ✭ 141 (-93.71%)
Mutual labels:  xcode, cocoapods
Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (-94.15%)
Mutual labels:  xcode, cocoapods
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+1546.41%)
Mutual labels:  xcode, cocoapods
Accordionswift
The best way of implement an accordion menu using an UITableView in Swift
Stars: ✭ 156 (-93.04%)
Mutual labels:  xcode, cocoapods
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+377.73%)
Mutual labels:  xcode, cocoapods
Shari
Shari is the alternative to the library of UIPickerView(drum roll) in Swift. You can select a item using UITableView.
Stars: ✭ 111 (-95.05%)
Mutual labels:  xcode, cocoapods
Nextgrowingtextview
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
Stars: ✭ 1,540 (-31.28%)
Mutual labels:  xcode, cocoapods
Croc
Swift emoji string parsing library
Stars: ✭ 124 (-94.47%)
Mutual labels:  xcode, cocoapods
Mscircularslider
A fully-featured, powerful circular slider for iOS applications
Stars: ✭ 94 (-95.81%)
Mutual labels:  xcode, cocoapods
Pluggableappdelegate
!! No longer supported !! A lightweight service-oriented AppDelegate for iOS, made in Swift.
Stars: ✭ 96 (-95.72%)
Mutual labels:  xcode, cocoapods
Testdrive
Quickly try out any Swift pod or framework in a playground
Stars: ✭ 1,612 (-28.07%)
Mutual labels:  xcode, cocoapods
Swiftcolorgen
A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
Stars: ✭ 152 (-93.22%)
Mutual labels:  xcode, cocoapods

Version Platform Language SPM Support License

Tiercel 是一个简单易用、功能丰富的纯 Swift 下载框架,支持原生级别后台下载,拥有强大的任务管理功能,可以满足下载类 APP 的大部分需求。

如果你使用的开发语言是 Objective-C ,可以使用 TiercelObjCBridge 进行桥接

Tiercel 3.0

Tiercel 3.0 大幅提高了性能,拥有更完善的错误处理,提供了更多方便的 API。从 Tiercel 2.0 升级到 Tiercel 3.0 是很简单的,强烈推荐所有开发者都进行升级,具体请查看 Tiercel 3.0 迁移指南

特性

  • 支持原生级别的后台下载
  • 支持离线断点续传,App 无论 crash 还是被手动 Kill 都可以恢复下载
  • 拥有精细的任务管理,每个下载任务都可以单独操作和管理
  • 支持创建多个下载模块,每个模块互不影响
  • 每个下载模块拥有单独的管理者,可以对总任务进行操作和管理
  • 支持批量操作
  • 内置了下载速度、剩余时间等常见的下载信息
  • 支持自定义日志
  • 支持下载任务排序
  • 链式语法调用
  • 支持控制下载任务的最大并发数
  • 支持文件校验
  • 线程安全

环境要求

  • iOS 10.0+
  • Xcode 11.0+
  • Swift 5.0+

安装

CocoaPods

Tiercel 支持 CocoaPods 集成,首先需要使用以下命令安装 CocoaPod:

$ gem install cocoapods

Podfile文件中

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'Tiercel'
end

最后运行命令

$ pod install

Swift Package Manager

从 Xcode 11 开始,集成了 Swift Package Manager,使用起来非常方便。Tiercel 也支持通过 Swift Package Manager 集成。

在 Xcode 的菜单栏中选择 File > Swift Packages > Add Pacakage Dependency,然后在搜索栏输入

[email protected]:Danie1s/Tiercel.git,即可完成集成

手动集成

Tiercel 也支持手动集成,只需把本项目文件夹中的Tiercel文件夹拖进需要集成的项目即可

Demo

打开本项目文件夹中 Tiercel.xcodeproj ,可以直接运行 Demo

用法

基本用法

一行代码开启下载

// 创建下载任务并且开启下载,同时返回可选类型的DownloadTask实例,如果url无效,则返回nil
let task = sessionManager.download("http://dldir1.qq.com/qqfile/QQforMac/QQ_V4.2.4.dmg")

// 批量创建下载任务并且开启下载,返回有效url对应的任务数组,urls需要跟fileNames一一对应
let tasks = sessionManager.multiDownload(URLStrings)

可以对任务设置状态回调

let task = sessionManager.download("http://dldir1.qq.com/qqfile/QQforMac/QQ_V4.2.4.dmg")

task?.progress(onMainQueue: true) { (task) in
    let progress = task.progress.fractionCompleted
    print("下载中, 进度:\(progress)")
}.success { (task) in
    print("下载完成")
}.failure { (task) in
    print("下载失败")
}

可以通过 URL 对下载任务进行操作,也可以直接操作下载任务

let URLString = "http://dldir1.qq.com/qqfile/QQforMac/QQ_V4.2.4.dmg"

// 通过 URL 对下载任务进行操作
sessionManager.start(URLString)
sessionManager.suspend(URLString)
sessionManager.cancel(URLString)
sessionManager.remove(URLString, completely: false)

// 直接对下载任务进行操作
sessionManager.start(task)
sessionManager.suspend(task)
sessionManager.cancel(task)
sessionManager.remove(task, completely: false)

后台下载

从 Tiercel 2.0 开始支持原生的后台下载,只要使用 Tiercel 开启了下载任务:

  • 手动 Kill App,任务会暂停,重启 App 后可以恢复进度,继续下载
  • 只要不是手动 Kill App,任务都会一直在下载,例如:
    • App 退回后台
    • App 崩溃或者被系统关闭
    • 重启手机

如果想了解后台下载的细节和注意事项,可以查看:iOS 原生级别后台下载详解

文件校验

Tiercel 提供了文件校验功能,可以根据需要添加,校验结果在回调的task.validation

let task = sessionManager.download("http://dldir1.qq.com/qqfile/QQforMac/QQ_V4.2.4.dmg")
// 回调闭包可以选择是否在主线程上执行
task?.validateFile(code: "9e2a3650530b563da297c9246acaad5c",
                   type: .md5,
                   onMainQueue: true)
                   { (task) in
    if task.validation == .correct {
        // 文件正确
    } else {
        // 文件错误
    }
}

更多

有关 Tiercel 3.0 的详细使用方法和升级迁移,请查看 Wiki

License

Tiercel is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].