{"id":32151773,"url":"https://github.com/swiftgram/tdlibkit","last_synced_at":"2026-04-27T04:02:00.407Z","repository":{"id":37278270,"uuid":"386682104","full_name":"Swiftgram/TDLibKit","owner":"Swiftgram","description":"Native Swift wrapper for Telegram's TDLib. Available on iOS, macOS, watchOS, tvOS and visionOS.","archived":false,"fork":false,"pushed_at":"2026-04-25T01:46:13.000Z","size":36471,"stargazers_count":140,"open_issues_count":0,"forks_count":29,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-04-25T03:38:49.989Z","etag":null,"topics":["ios","library","macos","swift","swift-async","tdlib","telegram","tvos","visionos","watchos"],"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/Swiftgram.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-16T15:25:10.000Z","updated_at":"2026-04-15T13:18:19.000Z","dependencies_parsed_at":"2025-12-13T15:05:04.113Z","dependency_job_id":null,"html_url":"https://github.com/Swiftgram/TDLibKit","commit_stats":null,"previous_names":[],"tags_count":271,"template":false,"template_full_name":null,"purl":"pkg:github/Swiftgram/TDLibKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftgram%2FTDLibKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftgram%2FTDLibKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftgram%2FTDLibKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftgram%2FTDLibKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Swiftgram","download_url":"https://codeload.github.com/Swiftgram/TDLibKit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftgram%2FTDLibKit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32321940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ios","library","macos","swift","swift-async","tdlib","telegram","tvos","visionos","watchos"],"created_at":"2025-10-21T10:52:34.933Z","updated_at":"2026-04-27T04:02:00.389Z","avatar_url":"https://github.com/Swiftgram.png","language":"Swift","readme":"# TDLibKit\n\n[![CI](https://github.com/Swiftgram/TDLibKit/actions/workflows/ci.yml/badge.svg)](https://github.com/Swiftgram/TDLibKit/actions/workflows/ci.yml)\n\nTDLibKit is a native Swift wrapper for [TDLib](https://github.com/tdlib/td) with support for iOS, macOS, watchOS, tvOS and visionOS.\n\nPowered by pre-built multi-platform [TDLibFramework](https://github.com/Swiftgram/TDLibFramework) implementation\nof [TDLib](https://github.com/tdlib/td) and generated sources with [tl2swift](scripts/tl2swift)\n\n## Installation\n\n### Xcode\n\n1. Install Latest Xcode\n2. Add `https://github.com/Swiftgram/TDLibKit` as SPM dependency in `Project \u003e Swift Packages`. This could take a while\n   cause it downloads ~300mb zip file with binary\n   from [TDLibFramework dependency](https://github.com/Swiftgram/TDLibFramework)\n3. Add `TDLibKit` as your target dependency.\n4. Code!\n\n### Cocoapods\n\nIntegration requires similar\nto [TDLibFramework Cocoapods \u0026 Flutter guide](https://github.com/Swiftgram/TDLibFramework/blob/main/docs/COCOAPODS-and-FLUTTER.md)\nadaptation.\n\n## Usage\n\nLibrary provides multiple API interfaces based on different approaches\n\n- [Async/Await](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/) syntax \u0026 do/catch. Available for iOS\n  13.0+, macOS 10.15+, watchOS 6.0+, tvOS 13.0+, visionOS\n- Completion handlers \u0026 closures\n\n### Create client Manager\n\n```swift\nimport TDLibKit\nlet manager = TDLibClientManager()\n```\n\nMake sure to create only one `TDLibClientManager`, since `td_receive` can be only called from a single thread.\n\nManager automatically polls for new updates, we will handle them per-client below.\n\n### Create Client \u0026 Handle updates\n\n```swift\nlet client = manager.createClient(updateHandler: { /* data: Data, client: TDLibCLient */\n    do {\n        let update = try $1.decoder.decode(Update.self, from: $0)\n        switch update {\n            case .updateNewMessage(let newMsg):\n                switch newMsg.message.content {\n                    case .messageText(let text):\n                        print(\"Text Message: \\(text.text.text)\")\n                    default:\n                        break\n                }\n            case .updateMessageEdited:\n                break\n                \n            // ... etc\n\n            default:\n                print(\"Unhandled Update \\(update)\")\n                break\n        }\n    } catch {\n        print(\"Error in update handler \\(error.localizedDescription)\")\n    }\n})\n```\n\n### Synchronious requests\n\nOnly for methods\nwith \"[Can be called synchronously](https://github.com/tdlib/td/blob/73d8fb4b3584633b0ffde97a20bbff6602e7a5c4/td/generate/scheme/td_api.tl#L4294)\"\nin docs\n\n```swift\nlet query = SetLogVerbosityLevel(newVerbosityLevel: 5)\ndo {\n    let result = try client.execute(query: DTO(query))\n    if let resultDict = result {\n        print(\"Response: \\(resultDict)\")\n    } else {\n        print(\"Empty result\")\n    }\n} catch {\n    print(\"Error in SetLogVerbosityLevel request \\(error.localizedDescription)\")\n}\n```\n\n### Async requests\n\n#### Async/Await\n\n```swift\ndo {\n    let chatHistory = try await client.getChatHistory(\n        chatId: chatId,\n        fromMessageId: 0,\n        limit: 50,\n        offset: 0,\n        onlyLocal: false // Request remote messages from server\n    )\n\n    for message in chatHistory.messages {\n    switch message.content {\n        case .messageText(let text):\n            print(text.text.text)\n            \n        case .messageAnimation:\n            print(\"\u003cAnimation\u003e\")\n            \n        case .messagePhoto(let photo):\n            print(\"\u003cPhoto\u003e\\n\\(photo.caption.text)\")\n            \n        case .messageSticker(let sticker):\n            print(sticker.sticker.emoji)\n            \n        case .messageVideo(let video):\n            print(\"\u003cVideo\u003e\\n\\(video.caption.text)\")\n            \n            // ...\n            \n        default:\n            print(\"Unknown message content \\(message.content)\")\n        }\n    }\n} catch {\n    print(\"Error in getChatHistory \\(error)\")\n}\n```\n\n#### Completion Handlers\n\n```swift\ntry? client.getChatHistory(\n    chatId: chatId,\n    fromMessageId: 0,\n    limit: 50,\n    offset: 0,\n    onlyLocal: false, // Request remote messages from server\n    completion: { result in\n        // Handle Errors\n        if case .failure(let error) = result {\n            print(\"Error in getChatHistory request \\(error.localizedDescription)\")\n        } else if let messages = try? result.get().messages {\n            // Handle messages\n            for message in messages {\n                switch message.content {\n                case .messageText(let text):\n                    print(text.text.text)\n                    \n                case .messageAnimation:\n                    print(\"\u003cAnimation\u003e\")\n                    \n                case .messagePhoto(let photo):\n                    print(\"\u003cPhoto\u003e\\n\\(photo.caption.text)\")\n                    \n                case .messageSticker(let sticker):\n                    print(sticker.sticker.emoji)\n                    \n                case .messageVideo(let video):\n                    print(\"\u003cVideo\u003e\\n\\(video.caption.text)\")\n                    \n                    // ...\n                    \n                default:\n                    print(\"Unknown message content \\(message.content)\")\n                }\n            }\n        }\n    }\n)\n```\n\n### Logging\n\nYou can pass additional parameter with `Logger` type to log \"send, receive, execute\" and custom entries.\n\n```swift\nimport TDLibKit\npublic final class StdOutLogger: TDLibLogger {\n    \n    let queue: DispatchQueue\n    \n    public init() {\n        queue = DispatchQueue(label: \"Logger\", qos: .userInitiated)\n    }\n    \n    public func log(_ message: String, type: LoggerMessageType?) {\n        queue.async {\n            var fisrtLine = \"---------------------------\"\n            if let type = type {\n                fisrtLine = \"\u003e\u003e \\(type.description): ---------------\"\n            }\n            print(\"\"\"\n                \\(fisrtLine)\n                \\(message)\n                ---------------------------\n                \"\"\")\n        }\n    }\n}\n\n\nlet manager = TDLibClientManager(logger: StdOutLogger())\n```\n\n### Close client\n\nTo ensure data integrity, you must properly close all the clients on app termination, either with\n    \n```swift\nlet client = manager.createClient()\ntry? client.close(completion: { _ in })\n```\n\nor use a blocking function\n\n```swift\nmanager.closeClients()\n```\n\n## Build\n\nYou can find more about build process in [Github Actions](.github/workflows/ci.yml) file.\n\n## Credits\n\n- Anton Glezman for [Build Guide](https://github.com/modestman/tdlib-swift)\n  , [TL Scheme parser](https://github.com/modestman/tl2swift) and basic implementation\n- Leo Mehlig for [TDLib-iOS](https://github.com/leoMehlig/TDLib-iOS) and contributions to run TDLib on Swift\n- Telegram Team for [TDLib](https://github.com/tdlib/td)\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftgram%2Ftdlibkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftgram%2Ftdlibkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftgram%2Ftdlibkit/lists"}