{"id":32148855,"url":"https://github.com/arasan01/swift-dependencies-extras","last_synced_at":"2026-02-18T22:01:29.121Z","repository":{"id":209796426,"uuid":"724386314","full_name":"arasan01/swift-dependencies-extras","owner":"arasan01","description":"Libraries that make swift-dependencies even more useful","archived":false,"fork":false,"pushed_at":"2023-12-06T16:34:14.000Z","size":73,"stargazers_count":10,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-14T19:47:43.378Z","etag":null,"topics":["macros","swift","xcode"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/arasan01/swift-dependencies-extras/","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/arasan01.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}},"created_at":"2023-11-28T01:06:18.000Z","updated_at":"2026-02-05T02:42:09.000Z","dependencies_parsed_at":"2023-12-03T19:45:12.055Z","dependency_job_id":null,"html_url":"https://github.com/arasan01/swift-dependencies-extras","commit_stats":null,"previous_names":["arasan01/swift-dependencies-extras"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/arasan01/swift-dependencies-extras","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arasan01%2Fswift-dependencies-extras","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arasan01%2Fswift-dependencies-extras/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arasan01%2Fswift-dependencies-extras/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arasan01%2Fswift-dependencies-extras/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arasan01","download_url":"https://codeload.github.com/arasan01/swift-dependencies-extras/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arasan01%2Fswift-dependencies-extras/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["macros","swift","xcode"],"created_at":"2025-10-21T09:16:12.112Z","updated_at":"2026-02-18T22:01:29.112Z","avatar_url":"https://github.com/arasan01.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dependencies Protocol Extras\n\nLibrary to make swift-dependencies even more useful when using Protocol.\n\n## Table of Contents\n\n- [Dependencies Protocol Extras](#dependencies-protocol-extras)\n  - [Table of Contents](#table-of-contents)\n  - [Overview](#overview)\n  - [Quick start](#quick-start)\n  - [Documentation](#documentation)\n  - [Installation](#installation)\n  - [Now on provide.](#now-on-provide)\n    - [Dependencies Extras Macros](#dependencies-extras-macros)\n  - [License](#license)\n\n## Overview\n\nXcode's support for protocol-oriented declarations and implementations is very strong. However, as we understood in the Point-Free episode, we pay a price for this in exchange for some flexibility. So is there a way to move things forward while getting the benefits of both? Yes, that is macros! Macros allow us to automatically convert protocol-based to struct-based. This is an approach that works very well. By depositing the implementation in the macro, the protocol becomes an entity to be assisted by Xcode, and is internally converted into a function call of the implementation.\n\nThis is a library that extends swift-dependencies, swift-dependencies is here.\n\nhttps://github.com/pointfreeco/swift-dependencies\n\n## Quick start\n\nLook at this first. Swift The power of Macro makes it possible to cut out and rewrite a single function, even if it is implemented in a protocol.\n\n```swift\nimport DependenciesExtrasMacros\nimport Foundation\n\n@DependencyProtocolClient(implemented: ProtocolPersistentImpl.self)\nprotocol ProtocolPersistent: Sendable {\n    func load(_ url: URL) throws -\u003e Data\n    func save(_ data: Data, _ url: URL) async throws -\u003e Void\n}\n\npublic final class ProtocolPersistentImpl: @unchecked Sendable, ProtocolPersistent {\n    func load(_ url: URL) throws -\u003e Data { try Data(contentsOf: url) }\n    func save(_ data: Data, _ url: URL) async throws -\u003e Void { try data.write(to: url) }\n}\n\nextension DependencyValues {\n    #DependencyValueRegister(of: ProtocolPersistent.self, into: \"protocolPersistent\")\n}\n\nstruct Runner {\n    @Dependency(\\.protocolPersistent) var protocolPersistent\n\n    func run() async throws {\n        do {\n            let new = withDependencies {\n                $0.protocolPersistent.save = { data, url in debugPrint(data, url) }\n            } operation: {\n                protocolPersistent\n            }\n            try await new.save(\"struct\".data(using: .utf8)!, URL.documentsDirectory.appendingPathComponent(UUID().uuidString, conformingTo: .text))\n        }\n    }\n}\n```\n\nThe first step is to give the already existing protocol a macro that informs the world that this will be used for dependency resolution.\n\n```diff\n+ @DependencyProtocolClient(implemented: ProtocolPersistentImpl.self)\n  protocol ProtocolPersistent: Sendable {\n    func load(_ url: URL) throws -\u003e Data\n    func save(_ data: Data, _ url: URL) async throws -\u003e Void\n  }\n```\n\nNext, register a structure in DependencyValues that conforms to the DependencyKey generated by the macro\n\n```diff\n+ extension DependencyValues {\n+   #DependencyValueRegister(of: ProtocolPersistent.self, into: \"protocolPersistent\")\n+ }\n```\n\nThis ends the need for us to be hands on! This is the only way things will start to work. If it doesn't work or has behavior you don't expect, please give us feedback. We welcome your contribution!\n\n## Documentation\n\nThe latest documentation for the Dependencies APIs is available [here][docs].\n\n## Installation\n\nYou can add Dependencies to an Xcode project by adding it to your project as a package.\n\n\u003e https://github.com/arasan01/swift-dependencies-extras\n\nIf you want to use Dependencies in a [SwiftPM](https://swift.org/package-manager/) project, it's as\nsimple as adding it to your `Package.swift`:\n\n``` swift\ndependencies: [\n  .package(url: \"https://github.com/arasan01/swift-dependencies-extras\", from: \"0.1.0\")\n]\n```\n\nAnd then adding the product to any target that needs access to the library:\n\n```swift\n.product(name: \"DependenciesExtrasMacros\", package: \"swift-dependencies-extras\"),\n```\n\n## Now on provide.\n\n### Dependencies Extras Macros\n\nAutomatically rewrite the conventional design consisting of Protocol, Class, and Struct based on swift-dependencies in PointFree style, allowing rewriting of each implemented function one by one.\n\n## License\n\nThis library is released under the MIT license. See [LICENSE](LICENSE) for details.\n\n[docs]: https://swiftpackageindex.com/arasan01/swift-dependencies-extras/main/documentation/dependenciesextrasmacros\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farasan01%2Fswift-dependencies-extras","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farasan01%2Fswift-dependencies-extras","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farasan01%2Fswift-dependencies-extras/lists"}