{"id":20918224,"url":"https://github.com/almazrafi/autochangeable","last_synced_at":"2025-05-13T12:31:18.104Z","repository":{"id":41783217,"uuid":"269077856","full_name":"almazrafi/AutoChangeable","owner":"almazrafi","description":"Convenient way to copy instances of Swift types with changed properties","archived":false,"fork":false,"pushed_at":"2023-01-25T03:26:35.000Z","size":55,"stargazers_count":18,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-31T16:12:09.701Z","etag":null,"topics":["carthage","cocoapods","ios","macos","spm","swift","tvos","watchos","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/almazrafi.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}},"created_at":"2020-06-03T12:07:28.000Z","updated_at":"2023-05-19T09:58:16.000Z","dependencies_parsed_at":"2023-02-08T15:16:13.409Z","dependency_job_id":null,"html_url":"https://github.com/almazrafi/AutoChangeable","commit_stats":null,"previous_names":["almazrafi/changeablecopy"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almazrafi%2FAutoChangeable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almazrafi%2FAutoChangeable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almazrafi%2FAutoChangeable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almazrafi%2FAutoChangeable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/almazrafi","download_url":"https://codeload.github.com/almazrafi/AutoChangeable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225209314,"owners_count":17438214,"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":["carthage","cocoapods","ios","macos","spm","swift","tvos","watchos","xcode"],"created_at":"2024-11-18T16:38:12.619Z","updated_at":"2024-11-18T16:38:13.258Z","avatar_url":"https://github.com/almazrafi.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AutoChangeable\n[![Build Status](https://github.com/almazrafi/AutoChangeable/workflows/CI/badge.svg?branch=main)](https://github.com/almazrafi/AutoChangeable/actions)\n[![Codecov](https://codecov.io/gh/almazrafi/AutoChangeable/branch/master/graph/badge.svg)](https://codecov.io/gh/almazrafi/AutoChangeable)\n[![Cocoapods](https://img.shields.io/cocoapods/v/AutoChangeable)](http://cocoapods.org/pods/AutoChangeable)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-Compatible-brightgreen)](https://github.com/Carthage/Carthage)\n[![SPM compatible](https://img.shields.io/badge/SPM-Compatible-brightgreen.svg)](https://swift.org/package-manager/)\n[![Platforms](https://img.shields.io/cocoapods/p/AutoChangeable)](https://developer.apple.com/discover/)\n[![Xcode](https://img.shields.io/badge/Xcode-12-blue)](https://developer.apple.com/xcode)\n[![Swift](https://img.shields.io/badge/Swift-5.1-orange)](https://swift.org)\n[![License](https://img.shields.io/github/license/almazrafi/AutoChangeable)](https://opensource.org/licenses/MIT)\n\nAutoChangeable is a simple library that provides a convenient way to copy instances of Swift types with changed properties:\n\n```swift\nstruct User: AutoChangeable {\n    let id: Int\n    let name: String\n    let age: Int\n}\n\nlet steve = User(id: 1, name: \"Steve\", age: 21)\n\n// Copy the instance by changing the `name` and `age` properties\nlet steveJobs = steve.changing { newUser in\n    newUser.name = \"Steve Jobs\"\n    newUser.age = 41\n}\n```\n\n## Requirements\n- iOS 10.0+ / macOS 10.12+ / watchOS 3.0+ / tvOS 10.0+\n- Xcode 12.5+\n- Swift 5.1+\n\n## Usage\nThe most convenient way to use AutoChangeable is to configure [code generation](#code-generation)\nand conform your structs to the `AutoChangeable` protocol:\n\n```swift\nstruct User: AutoChangeable {\n    let id: Int\n    let name: String\n    let age: Int\n}\n```\n\nIf you don't want to configure code generation,\nyou just need to implement initialization from a copy **manually**:\n\n```swift\nextension User: Changeable {\n    init(copy: ChangeableWrapper\u003cSelf\u003e) {\n        self.init(\n            id: copy.id,\n            name: copy.name,\n            age: copy.age\n        )\n    }\n}\n```\n\n## Installation\n### CocoaPods\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n```bash\n$ gem install cocoapods\n```\n\nTo integrate AutoChangeable into your Xcode project using [CocoaPods](http://cocoapods.org), specify it in your `Podfile`:\n```ruby\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'AutoChangeable'\nend\n```\n\nFinally run the following command:\n```bash\n$ pod install\n```\n\n### Carthage\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. You can install Carthage with Homebrew using the following command:\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate AutoChangeable into your Xcode project using Carthage, specify it in your `Cartfile`:\n```ogdl\ngithub \"almazrafi/AutoChangeable\" ~\u003e 1.0.1\n```\n\nFinally run `carthage update` to build the framework and drag the built `AutoChangeable.framework` into your Xcode project.\n\n### Swift Package Manager\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.\n\nTo integrate AutoChangeable into your Xcode project using Swift Package Manager,\nadd the following as a dependency to your `Package.swift`:\n```swift\n.package(url: \"https://github.com/almazrafi/AutoChangeable.git\", from: \"1.0.1\")\n```\nand then specify `\"AutoChangeable\"` as a dependency of the Target in which you wish to use AutoChangeable.\n\nHere's an example `Package.swift`:\n```swift\n// swift-tools-version:5.0\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyPackage\",\n    products: [\n        .library(name: \"MyPackage\", targets: [\"MyPackage\"])\n    ],\n    dependencies: [\n        .package(url: \"https://github.com/almazrafi/AutoChangeable.git\", from: \"1.0.1\")\n    ],\n    targets: [\n        .target(name: \"MyPackage\", dependencies: [\"AutoChangeable\"])\n    ]\n)\n```\n\n## Code Generation\nTo generate code for the `AutoChangeable` protocol, the first thing you need to do\nis to install the [Sourcery](https://github.com/krzysztofzablocki/Sourcery) command line tool.\n\nYou can use a ready-made [Stencil](https://github.com/stencilproject/Stencil)-template for Sourcery,\nwhich can be downloaded from the latest release files\non the [repository releases page](https://github.com/almazrafi/AutoChangeable/releases).\n\nIf AutoChangeable is installed using CocoaPods, it already contains this template\nand a helper script for generating code.\nYou can either run it manually or in a custom build phase using the following command:\n\n``` sh\nPods/AutoChangeable/Bin/AutoChangeable \\\n--sources Path/to/yours/sources \\\n--output Path/to/generated/file\n```\n\n## Communication\n- If you need help, open an issue.\n- If you found a bug, open an issue.\n- If you have a feature request, open an issue.\n- If you want to contribute, submit a pull request.\n\n## License\nAutoChangeable is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falmazrafi%2Fautochangeable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falmazrafi%2Fautochangeable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falmazrafi%2Fautochangeable/lists"}