{"id":21064603,"url":"https://github.com/capturecontext/swift-capture","last_synced_at":"2025-10-11T20:33:26.058Z","repository":{"id":63906743,"uuid":"393677860","full_name":"CaptureContext/swift-capture","owner":"CaptureContext","description":"A mechanism for safe capturing \u0026 weakifying objects in Swift.","archived":false,"fork":false,"pushed_at":"2024-09-21T19:15:17.000Z","size":35,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-02T03:59:48.419Z","etag":null,"topics":["arc","memory-management","spm","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/CaptureContext/swift-capture/3.0.1/documentation","language":"Swift","has_issues":false,"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/CaptureContext.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}},"created_at":"2021-08-07T12:29:10.000Z","updated_at":"2023-11-03T09:48:38.000Z","dependencies_parsed_at":"2022-11-28T22:46:39.691Z","dependency_job_id":"b9d6983a-655d-46a4-9f77-c0b2ab6008ba","html_url":"https://github.com/CaptureContext/swift-capture","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":"0.33333333333333337","last_synced_commit":"fe8eb8687fe6880d5b757ed716e782f8d17d3fb2"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/CaptureContext/swift-capture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-capture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-capture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-capture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-capture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CaptureContext","download_url":"https://codeload.github.com/CaptureContext/swift-capture/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-capture/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008617,"owners_count":26084480,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"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":["arc","memory-management","spm","swift","swift-package-manager"],"created_at":"2024-11-19T17:50:12.994Z","updated_at":"2025-10-11T20:33:26.039Z","avatar_url":"https://github.com/CaptureContext.png","language":"Swift","readme":"# swift-capture\n\n[![test](https://github.com/CaptureContext/swift-capture/actions/workflows/Test.yml/badge.svg)](https://github.com/CaptureContext/swift-capture/actions/workflows/Test.yml) [![SwiftPM 5.9](https://img.shields.io/badge/📦_swiftpm-5.9-ED523F.svg?style=flat)](https://github.com/CaptureContext/swift-declarative-configuration/actions/workflows/Test.yml) ![Platforms](https://img.shields.io/badge/platforms-iOS_|_macOS_|_tvOS_|_watchOS_|_Catalyst-ED523F.svg?style=flat)\n[![docs](https://img.shields.io/badge/docs-spi-ED523F.svg?style=flat)]([https://twitter.com/capture_context](https://swiftpackageindex.com/CaptureContext/swift-capture/3.0.1/documentation)) [![@capture_context](https://img.shields.io/badge/contact-@capture__context-1DA1F2.svg?style=flat\u0026logo=twitter)](https://twitter.com/capture_context) \n\nA mechanism for ergonomic and safe capturing \u0026 weakifying objects in Swift.\n\n## Usage Examples\n\n```swift\nWithout Capture\n```\n\n```swift\nWith Capture\n```\n\n----\n\nDefault\n```swift\n{ [weak self] in \n  guard let self else { return }\n  /// ...\n}\n```\n\n```swift\ncapture { _self in\n  /// ...\n}\n```\n\n----\n\nMultiple parameters\n```swift\n{ [weak self] a, b, c in \n  guard let self else { return }\n  /// ...\n}\n```\n\n```swift\ncapture { _self, a, b, c in \n  /// ...\n}\n```\n\n---\n\nMethods\n\n```swift\n{ [weak self] in \n  guard let self = self else { return }\n  self.someMethod()\n}\n```\n\n```swift\ncapture(in: \u003c#Type#\u003e.someMethod)\n```\n\n----\n\nReturn values\n\n```swift\nlet object.dataSource = { [weak self] in\n  guard let self = self else { return [] }\n  return self.data\n}\n```\n\n```swift\nlet object.dataSource = capture(orReturn: [], in: \\.data)\n```\n\n## Installation\n\n### Basic\n\nYou can add `swift-capture` to an Xcode project by adding it as a package dependency.\n\n1. From the **File** menu, select **Swift Packages › Add Package Dependency…**\n2. Enter [`\"https://github.com/capturecontext/swift-capture\"`](https://github.com/capturecontext/swift-capture) into the package repository URL text field\n3. Choose products you need to link them to your project.\n\n### Recommended\n\nIf you use SwiftPM for your project, you can add `weak` to your package file. Also my advice is to use SSH.\n\n```swift\n.package(\n  url: \"git@github.com:capturecontext/swift-capture.git\",\n  .upToNextMajor(\"3.0.0\")\n)\n```\n\nDo not forget about target dependencies:\n\n```swift\n.product(\n    name: \"Capture\", \n    package: \"swift-capture\"\n)\n```\n\n## License\n\nThis library is released under the MIT license. See [LICENSE](./LICENSE) for details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapturecontext%2Fswift-capture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapturecontext%2Fswift-capture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapturecontext%2Fswift-capture/lists"}