{"id":30179902,"url":"https://github.com/capturecontext/swift-sharing-extensions","last_synced_at":"2025-08-12T06:50:58.102Z","repository":{"id":307151350,"uuid":"1027728982","full_name":"CaptureContext/swift-sharing-extensions","owner":"CaptureContext","description":"Extensions for swift-sharing package","archived":false,"fork":false,"pushed_at":"2025-07-28T12:57:44.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-10T11:51:13.010Z","etag":null,"topics":["shared-state","structural-keys","swift","swift-sharing","user-defaults","user-defaults-manager","userdefaults"],"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/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":"2025-07-28T12:52:52.000Z","updated_at":"2025-07-28T13:07:45.000Z","dependencies_parsed_at":"2025-07-29T19:48:15.674Z","dependency_job_id":"ba9d1344-191d-4d72-a5ce-cfe97984d224","html_url":"https://github.com/CaptureContext/swift-sharing-extensions","commit_stats":null,"previous_names":["capturecontext/swift-sharing-extensions"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/CaptureContext/swift-sharing-extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-sharing-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-sharing-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-sharing-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-sharing-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CaptureContext","download_url":"https://codeload.github.com/CaptureContext/swift-sharing-extensions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptureContext%2Fswift-sharing-extensions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270017353,"owners_count":24512973,"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-08-12T02:00:09.011Z","response_time":80,"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":["shared-state","structural-keys","swift","swift-sharing","user-defaults","user-defaults-manager","userdefaults"],"created_at":"2025-08-12T06:50:56.349Z","updated_at":"2025-08-12T06:50:58.091Z","avatar_url":"https://github.com/CaptureContext.png","language":"Swift","readme":"# swift-sharing-extensions [beta]\n\n[![SwiftPM 6.2](https://img.shields.io/badge/swiftpm-6.2-ED523F.svg?style=flat)](https://swift.org/download/) ![Platforms](https://img.shields.io/badge/Platforms-iOS_13_|_macOS_10.15_|_Catalyst_|_tvOS_14_|_watchOS_7-ED523F.svg?style=flat) [![@capture_context](https://img.shields.io/badge/contact-@capture__context-1DA1F2.svg?style=flat\u0026logo=twitter)](https://twitter.com/capture_context) \n\nExtensions for [`swift-sharing`](https://github.com/pointfreeco/swift-sharing) package\n\n## Products\n\n- **[SharingKeys](./Sources/SharingKeys)**\n\n  Provides `SharedReaderKey` and `Shared` initializers structural key declarations\n  \n- **[SharingKeysCore](./Sources/SharingKeysCore)**\n  \n  Provides helpers for structural key declarations\n\n## Usage\n\n### SharingKeysCore\n\n##### Declaration\n\nExtend `AppStorageKeys` or `InMemoryStorageKeys` and specify available domains.\n\n```swift\nimport SharingKeysCore\n\nextension InMemoryStorageKeys {\n\tenum FirstDomain: Sendable {\n\t\tenum ChildDomain: Sendable {}\n\t}\n\n\tenum OtherDomain: Sendable {\n\t\tenum ChildDomain1: Sendable {}\n\t\tenum ChildDomain2: Sendable {}\n\t}\n}\n```\n\nSpecify accessors by extending  `StorageKeyBuilder` type\n\n```swift\nextension StorageKeyBuilder\u003cInMemoryStorageKeys\u003e {\n\tvar firstDomain: Subdomain\u003cInMemoryStorageKeys.FirstDomain\u003e { subdomain() }\n\tvar otherDomain: Subdomain\u003cInMemoryStorageKeys.OtherDomain\u003e { subdomain() }\n  \n  /// Final key will be \"first_domain-some_entry\"\n  /// And will have the same value as `InMemoryStorageKeys[\\.firstDomain.someEntry]`\n  var rawEntry: Entry { \"first_domain-some_entry\" } \n}\n\nextension StorageKeyBuilder\u003cInMemoryStorageKeys.FirstDomain\u003e {\n\tvar childDomain: Subdomain\u003cDomain.ChildDomain\u003e { subdomain() }\n  \n  /// Final key will be \"first_domain-some_entry\"\n\tvar someEntry: Entry { entry() }\n}\n\nextension StorageKeyBuilder\u003cInMemoryStorageKeys.FirstDomain.ChildDomain\u003e {\n  /// Final key will be \"first_domain-child_domain-some_entry\"\n  /// Strict entries are type-checked at call site\n  var someProtectedEntry: Entry.Strict\u003cInt\u003e { entry() }\n}\n\nextension StorageKeyBuilder\u003cInMemoryStorageKeys.OtherDomain\u003e {\n  /// Final key will be \"stringLiteral key\"\n  var customEntry: Entry { \"stringLiteral key\" }\n  \n  /// Final key will be \"other_domain###FORMATTEDENTRY\"\n  var formattedEntry: Entry { entry(format: .upper, separator: \"###\") }\n  \n  /// Final key will be \"other_domain###KEY\"\n  var formattedEntry2: Entry { entry(\"key\", format: .upper, separator: \"###\") }\n  \n  var randomPropertyName: Subdomain\u003cDomain.ChildDomain1\u003e { \n    // Subdomains can be modified just as entries, however subdomains are not\n    // ExpressibleByStringLiteral and must be created with a `subdomain` method\n  \tsubdomain(\"weCould fix The name_here\", format: .camel, separator: \"---\")\n  }\n}\n\nextension StorageKeyBuilder\u003cInMemoryStorageKeys.OtherDomain.ChildDomain1\u003e {\n  /// Final key will be \"other_domain---weCouldFixTheNameHere-value\"\n  var value: Entry { entry() } \n}\n\n// ...\n```\n\n\u003e [!NOTE]\n\u003e As you might have noticed\n\u003e\n\u003e - Default formatting for keys is snake_casing components and joining them with `\"-\"`\n\u003e - String literal keys bypass the formatting\n\u003e - Custom format and leading separator can be specified for each component\n\u003e\n\u003e This package uses [`swift-casification`](https://github.com/capturecontext/swift-casification) for formatting\n\nAccess your shared state in one of two ways\n\n```swift\nimport Sharing\nimport SharingKeys\n\n@Shared(\\.inMemory.keyPath.toEntry)\nvar value: Int = 0\n```\n\n```swift\n@Shared(.inMemory(\\.keyPath.toEntry))\nvar value: Int = 0\n```\n\n\n\n## Installation\n\n### Basic\n\nYou can add swift-sharing-extensions 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-sharing-extensions\"`](https://github.com/capturecontext/swift-sharing-extensions) 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 structure, add DeclarativeConfiguration to your package file. \n\n```swift\n.package(\n  url: \"git@github.com:capturecontext/swift-sharing-extensions.git\", \n  .upToNextMinor(from: \"0.0.1\")\n)\n```\nor via HTTPS\n\n```swift\n.package(\n  url: \"https://github.com:capturecontext/swift-sharing-extensions.git\", \n  .upToNextMinor(from: \"0.0.1\")\n)\n```\n\nDo not forget about target dependencies:\n\n```swift\n.product(\n  name: \"SharingKeys\", \n  package: \"swift-sharing-extensions\"\n)\n```\n\nor for the targets that don't need to read/write values to Shared storage but only to declare storage keys\n\n```swift\n.product(\n  name: \"SharingKeysCore\", \n  package: \"swift-sharing-extensions\"\n)\n```\n\n## License\n\nThis library is released under the MIT license. See [LICENSE](./LICENSE) for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapturecontext%2Fswift-sharing-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapturecontext%2Fswift-sharing-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapturecontext%2Fswift-sharing-extensions/lists"}