{"id":15027316,"url":"https://github.com/danie1s/tiercel","last_synced_at":"2025-05-14T19:02:22.862Z","repository":{"id":42789595,"uuid":"125603956","full_name":"Danie1s/Tiercel","owner":"Danie1s","description":"简单易用、功能丰富的纯 Swift 下载框架","archived":false,"fork":false,"pushed_at":"2024-06-17T13:35:07.000Z","size":37320,"stargazers_count":2663,"open_issues_count":2,"forks_count":385,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-10-29T11:27:45.756Z","etag":null,"topics":["cocoapods","download","ios","network","swift","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Danie1s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-17T06:41:16.000Z","updated_at":"2024-10-28T09:36:59.000Z","dependencies_parsed_at":"2024-06-17T15:06:13.872Z","dependency_job_id":"c6afa1a6-8af8-4466-aacb-bc18525f795f","html_url":"https://github.com/Danie1s/Tiercel","commit_stats":{"total_commits":138,"total_committers":8,"mean_commits":17.25,"dds":"0.49275362318840576","last_synced_commit":"203ef077ed3887cb8cb5729446ef018f890a8a9a"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danie1s%2FTiercel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danie1s%2FTiercel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danie1s%2FTiercel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danie1s%2FTiercel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Danie1s","download_url":"https://codeload.github.com/Danie1s/Tiercel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161261,"owners_count":21057552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","download","ios","network","swift","xcode"],"created_at":"2024-09-24T20:06:11.460Z","updated_at":"2025-04-10T04:51:16.454Z","avatar_url":"https://github.com/Danie1s.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=center\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/Danie1s/Tiercel/master/Images/logo.png\"/\u003e\n\u003c/div\u003e\n\n[![Version](https://img.shields.io/cocoapods/v/Tiercel.svg?style=flat)](http://cocoapods.org/pods/Tiercel)\n[![Platform](https://img.shields.io/cocoapods/p/Tiercel.svg?style=flat)](http://cocoapods.org/pods/Tiercel)\n[![Language](https://img.shields.io/badge/language-swift-red.svg?style=flat)]()\n[![SPM](https://img.shields.io/badge/SPM-supported-DE5C43.svg?style=flat)](https://swift.org/package-manager/)\n[![Support](https://img.shields.io/badge/support-iOS%2010%2B%20-brightgreen.svg?style=flat)](https://www.apple.com/nl/ios/)\n[![License](https://img.shields.io/cocoapods/l/Tiercel.svg?style=flat)](http://cocoapods.org/pods/Tiercel)\n\nTiercel 是一个简单易用、功能丰富的纯 Swift 下载框架，支持原生级别后台下载，拥有强大的任务管理功能，可以满足下载类 APP 的大部分需求。\n\n如果你使用的开发语言是 Objective-C ，可以使用 [TiercelObjCBridge](https://github.com/Danie1s/TiercelObjCBridge) 进行桥接\n\n- [Tiercel 3.0](#tiercel-30)\n- [特性](#特性)\n- [环境要求](#环境要求)\n- [集成](#集成)\n- [Demo](#demo)\n- [用法](#用法)\n  - [基本用法](#基本用法)\n  - [后台下载](#后台下载)\n  - [文件校验](#文件校验)\n  - [更多](#更多)\n- [License](#license)\n\n\n\n## Tiercel 3.0\n\nTiercel 3.0 大幅提高了性能，拥有更完善的错误处理，提供了更多方便的 API。从 Tiercel 2.0 升级到 Tiercel 3.0 是很简单的，强烈推荐所有开发者都进行升级，具体请查看 [Tiercel 3.0 迁移指南](https://github.com/Danie1s/Tiercel/wiki/Tiercel-3.0-%E8%BF%81%E7%A7%BB%E6%8C%87%E5%8D%97)\n\n## 特性\n\n- [x] 支持原生级别的后台下载\n- [x] 支持离线断点续传，App 无论 crash 还是被手动 Kill 都可以恢复下载\n- [x] 拥有精细的任务管理，每个下载任务都可以单独操作和管理\n- [x] 支持创建多个下载模块，每个模块互不影响\n- [x] 每个下载模块拥有单独的管理者，可以对总任务进行操作和管理\n- [x] 支持批量操作\n- [x] 内置了下载速度、剩余时间等常见的下载信息\n- [x] 支持自定义日志\n- [x] 支持下载任务排序\n- [x] 链式语法调用\n- [x] 支持控制下载任务的最大并发数\n- [x] 支持文件校验\n- [x] 线程安全\n\n\n\n## 环境要求\n\n- iOS 12.0+\n- Xcode 15.0+\n- Swift 5.0+\n\n\n\n## 安装\n\n### CocoaPods\n\nTiercel 支持 CocoaPods 集成，首先需要使用以下命令安装 CocoaPod：\n\n```bash\n$ gem install cocoapods\n```\n\n在`Podfile`文件中\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'Tiercel'\nend\n```\n\n最后运行命令\n\n```bash\n$ pod install\n```\n\n### Swift Package Manager\n\n从 Xcode 11 开始，集成了 Swift Package Manager，使用起来非常方便。Tiercel 也支持通过 Swift Package Manager 集成。\n\n在 Xcode 的菜单栏中选择 `File \u003e Swift Packages \u003e Add Pacakage Dependency`，然后在搜索栏输入\n\n`git@github.com:Danie1s/Tiercel.git`，即可完成集成\n\n### 手动集成\n\nTiercel 也支持手动集成，只需把本项目文件夹中的`Tiercel`文件夹拖进需要集成的项目即可\n\n\n\n## Demo\n\n打开本项目文件夹中 `Tiercel.xcodeproj` ，可以直接运行 Demo\n\n\u003cimg src=\"https://raw.githubusercontent.com/Danie1s/Tiercel/master/Images/1.gif\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/Danie1s/Tiercel/master/Images/2.gif\"\u003e\n\n\n## 用法\n\n### 基本用法\n\n一行代码开启下载\n\n```swift\n// 创建下载任务并且开启下载，同时返回可选类型的DownloadTask实例，如果url无效，则返回nil\nlet task = sessionManager.download(\"http://dldir1.qq.com/qqfile/QQforMac/QQ_V4.2.4.dmg\")\n\n// 批量创建下载任务并且开启下载，返回有效url对应的任务数组，urls需要跟fileNames一一对应\nlet tasks = sessionManager.multiDownload(URLStrings)\n```\n\n可以对任务设置状态回调\n\n```swift\nlet task = sessionManager.download(\"http://dldir1.qq.com/qqfile/QQforMac/QQ_V4.2.4.dmg\")\n\ntask?.progress(onMainQueue: true) { (task) in\n    let progress = task.progress.fractionCompleted\n    print(\"下载中, 进度：\\(progress)\")\n}.success { (task) in\n    print(\"下载完成\")\n}.failure { (task) in\n    print(\"下载失败\")\n}\n```\n\n可以通过 URL 对下载任务进行操作，也可以直接操作下载任务\n\n```swift\nlet URLString = \"http://dldir1.qq.com/qqfile/QQforMac/QQ_V4.2.4.dmg\"\n\n// 通过 URL 对下载任务进行操作\nsessionManager.start(URLString)\nsessionManager.suspend(URLString)\nsessionManager.cancel(URLString)\nsessionManager.remove(URLString, completely: false)\n\n// 直接对下载任务进行操作\nsessionManager.start(task)\nsessionManager.suspend(task)\nsessionManager.cancel(task)\nsessionManager.remove(task, completely: false)\n```\n\n\n\n### 后台下载\n\n从 Tiercel 2.0 开始支持原生的后台下载，只要使用 Tiercel 开启了下载任务：\n\n- 手动 Kill App，任务会暂停，重启 App 后可以恢复进度，继续下载\n- 只要不是手动 Kill App，任务都会一直在下载，例如：\n  - App 退回后台\n  - App 崩溃或者被系统关闭\n  - 重启手机\n\n如果想了解后台下载的细节和注意事项，可以查看：[iOS 原生级别后台下载详解](https://github.com/Danie1s/Tiercel/wiki/iOS-%E5%8E%9F%E7%94%9F%E7%BA%A7%E5%88%AB%E5%90%8E%E5%8F%B0%E4%B8%8B%E8%BD%BD%E8%AF%A6%E8%A7%A3)\n\n\n\n### 文件校验\n\nTiercel 提供了文件校验功能，可以根据需要添加，校验结果在回调的`task.validation`里\n\n```swift\n\nlet task = sessionManager.download(\"http://dldir1.qq.com/qqfile/QQforMac/QQ_V4.2.4.dmg\")\n// 回调闭包可以选择是否在主线程上执行\ntask?.validateFile(code: \"9e2a3650530b563da297c9246acaad5c\",\n                   type: .md5,\n                   onMainQueue: true)\n                   { (task) in\n    if task.validation == .correct {\n        // 文件正确\n    } else {\n        // 文件错误\n    }\n}\n```\n\n\n\n### 更多\n\n有关 Tiercel 3.0 的详细使用方法和升级迁移，请查看 [Wiki](https://github.com/Danie1s/Tiercel/wiki)\n\n\n\n\n## License\n\nTiercel is available under the MIT license. See the LICENSE file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanie1s%2Ftiercel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanie1s%2Ftiercel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanie1s%2Ftiercel/lists"}