{"id":21440339,"url":"https://github.com/rezojoglidze/rjswiftmacros","last_synced_at":"2026-03-02T11:01:04.149Z","repository":{"id":248409236,"uuid":"828553164","full_name":"rezojoglidze/RJSwiftMacros","owner":"rezojoglidze","description":"RJSwiftMacros is a Swift package that provides swift macros","archived":false,"fork":false,"pushed_at":"2025-09-13T13:21:44.000Z","size":244,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T00:20:10.403Z","etag":null,"topics":["codingkeys","codingkeys-xcode-extension","ios","ios-swift","library","macros","mock","mocking","opensource","swift","swift-package-manager","swiftmacros","swiftui","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/rezojoglidze.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-07-14T13:52:42.000Z","updated_at":"2025-08-16T12:31:27.000Z","dependencies_parsed_at":"2024-08-28T18:19:23.047Z","dependency_job_id":"04bc6724-e8f0-4521-a009-271f9700d7eb","html_url":"https://github.com/rezojoglidze/RJSwiftMacros","commit_stats":null,"previous_names":["rezojoglidze/rjswiftmacros"],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/rezojoglidze/RJSwiftMacros","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezojoglidze%2FRJSwiftMacros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezojoglidze%2FRJSwiftMacros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezojoglidze%2FRJSwiftMacros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezojoglidze%2FRJSwiftMacros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rezojoglidze","download_url":"https://codeload.github.com/rezojoglidze/RJSwiftMacros/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezojoglidze%2FRJSwiftMacros/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29999216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T09:59:02.300Z","status":"ssl_error","status_checked_at":"2026-03-02T09:59:02.001Z","response_time":60,"last_error":"SSL_read: 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":["codingkeys","codingkeys-xcode-extension","ios","ios-swift","library","macros","mock","mocking","opensource","swift","swift-package-manager","swiftmacros","swiftui","xcode"],"created_at":"2024-11-23T01:11:37.867Z","updated_at":"2026-03-02T11:01:04.130Z","avatar_url":"https://github.com/rezojoglidze.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RJSwiftMacros\n\nRJSwiftMacros is a Swift package that provides macros.\n\n\u003e [!TIP]\n\u003e All macros are used in SwiftUIDemo project. see the [LINK](https://github.com/rezojoglidze/SwiftUIDemo).\n\n## Macros\n\n\u003e [!WARNING]  \n\u003e `MockBuilder` macro doesn't work at `SwiftUI` `#Preview` macro. Here is a [solution](https://stackoverflow.com/questions/78856674/does-attached-macros-work-in-the-preview-body/78856731#78856731).\n\n### MockBuilder\n- ``MockBuilder(numberOfItems: Int)``: Generates a mock instance and an array of mock data based on your model.\n- `MockBuilder` has `MockBuilderProperty` member macro, with which you can set the initial value to the desired property.\n  \n##### Key Features:\n- **Default Usage**: `@MockBuilder()` generates a one single mock instance.\n- **Customizable**: You can also specify parameter like `numberOfItems` if you need to have array of mock items.\n\n#### MockBuilderProperty macro\n- ``MockBuilderProperty\u003cT: Any\u003e(value: T)``: Sets an initial value to a property within a struct or class. \n\n### CodingKeys\n- ``CodingKeys(codingKeyType: CodingKeyType)``: Automatically generates `CodingKeys` for a struct based on the specified `CodingKeyType` which has two cases: `.camelCase` and `.snakeCase`.\n- ``CodingKeyProperty(:_)``: Allows you to adjust the coding key for a specific property.\n- ``CodingKeyIgnored()``: Allows you to exclude specific properties from the coding process when using the `CodingKeys` macro.\n\n\n\n## Installation\n**Swift Package Manager**\n\nTo depend on `RJSwiftMacros` in a SwiftPM package, add the following to your Package.swift.\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/rezojoglidze/RJSwiftMacros\", from: \"\u003c#latest RJSwiftMacros tag#\u003e\"),\n],\n```\nTo add `RJSwiftMacros` as a dependency of your Xcode project, go to the Package Dependencies tab of your Xcode project, click the plus button and search for https://github.com/rezojoglidze/RJSwiftMacros\n\n## Usage\n\n### MockBuilder macro\nImport the RJSwiftMacros module and apply the macros to your structs and properties:\n\nUsage of `MockBuilder`: \nMacro generates two `static` properties: `mock` and `mockArray`. `mockArray` count equals `numberOfItems` value. If you want to set a custom value to the desired property, use `@MockBuilderProperty` macro. If the custom value granted is prohibited you will get a swift standard warning error. \u003cimg width=\"470\" alt=\"image\" src=\"https://github.com/user-attachments/assets/5467a640-0923-4421-9680-f7ae8e743e59\"\u003e\n\nTo generate only `.mock` value, you can use `@MockBuilder()` without any param passing.\n\u003e [!IMPORTANT]  \n\u003e Type which participating in the mock building should have `@MockBuilder()` itself. Below example, we want to have `let type: VehicleType` mocked version, so `VehicleType` should have `@MockBuilder()`\n```swift\nimport RJSwiftMacros\n\n@MockBuilder(numberOfItems: 2)\nenum VehicleType: String, Decodable {\n    case car\n    case bus\n    case motorcycle\n}\n\n@MockBuilder()\nstruct ExampleAllSupportedTypes {\n    let intVariable: Int\n    let int8Variable: Int8\n    let int16Variable: Int16\n    let int32Variable: Int32\n    let int64Variable: Int64\n    let uintVariable: UInt\n    let uint8Variable: UInt8\n    let uint16Variable: UInt16\n    let uint32Variable: UInt32\n    let uint64Variable: UInt64\n    let floatVariable: Float\n    let float32Variable: Float32\n    let float64Variable: Float64\n    let doubleVariable: Double\n    let decimalVariable: Decimal\n    let nsDecimalNumberVariable: NSDecimalNumber\n    let stringVariable: String\n    let boolVariable: Bool\n    let dateVariable: Date\n    let uuidVariable: UUID\n    let cgPointVariable: CGPoint\n    let cgRectVariable: CGRect\n    let cgSizeVariable: CGSize\n    let cgVectorVariable: CGVector\n    let cgFloatVariable: CGFloat\n    let urlVariable: URL\n    \n    let imageVariable: Image\n    let colorVariable: Color\n    \n    let vehicle: VehicleType\n    \n    let availableTimeSlot: Set\u003cString\u003e\n    \n    let arrayOfString: [String]\n    \n    let closureVariable: () -\u003e Void\n    \n    let tuples: ((String, String, Int), Bool?)\n\n    let passthroughSubject: PassthroughSubject\u003cBool, Never\u003e\n    let currentValueSubject: CurrentValueSubject\u003cVoid, Never\u003e\n}\n\n   #if DEBUG\n   public static var mock: ExampleAllSupportedTypes {\n       .init(\n           intVariable: 54248,\n           int8Variable: 92,\n           int16Variable: 17693,\n           int32Variable: 1748550107,\n           int64Variable: 85105,\n           uintVariable: 75340,\n           uint8Variable: 221,\n           uint16Variable: 6060,\n           uint32Variable: 34678,\n           uint64Variable: 4145,\n           floatVariable: 38105.523,\n           float32Variable: 99252.86,\n           float64Variable: 57161.44399989151,\n           doubleVariable: 45860.372174783995,\n           decimalVariable: 80414.91669166147584,\n           nsDecimalNumberVariable: 57109.7344805794816,\n           stringVariable: \"Lorem ipsum dolor sit amet\",\n           boolVariable: false,\n           dateVariable: Date(timeInterval: 77349, since: Date()),\n           uuidVariable: UUID(),\n           cgPointVariable: CGPoint(),\n           cgRectVariable: CGRect(),\n           cgSizeVariable: CGSize(),\n           cgVectorVariable: CGVector(),\n           cgFloatVariable: CGFloat(),\n           urlVariable: URL(string: \"https://www.tiktok.com\")!,\n           imageVariable: Image(systemName: \"swift\"),\n           colorVariable: Color.primary.opacity(0.6),\n           vehicle: VehicleType.mock,\n           availableTimeSlot: Set\u003cString\u003e(),\n           arrayOfString: [\"in voluptate velit esse cillum dolore\"]\n                    \"Duis aute irure dolor in reprehenderit\",\n                    \"Excepteur sint occaecat cupidatat non proident\",\n                    \"sed do eiusmod tempor incididunt\",\n                  ],\n           closureVariable: {},\n           tuples: ((\"Duis ac tellus et risus vulputate vehicula\", \"Duis aute irure dolor in reprehenderit\", 42372),false),\n           passthroughSubject: PassthroughSubject\u003cBool, Never\u003e(),\n           currentValueSubject: CurrentValueSubject\u003cVoid, Never\u003e(())\n           )\n    }\n    #endif\n}\n```\n\nTo generate both `.mock` and `.mockArray` properties use `@MockBuilder(numberOfItems: 2)`. `numberOfItems` is equal to the count of mock array.\n```swift\nimport RJSwiftMacros\n\n@MockBuilder(numberOfItems: 2)\nstruct Person {\n    let name: String?\n    let surname: [String]?\n    \n    @MockBuilderProperty(value: Color.blue) let color: Color?\n    @MockBuilderProperty(value: Image(systemName: \"swift\")) let image: Image?\n    @MockBuilderProperty(value: \"k\") let character: Character\n\n    #if DEBUG\n    static var mock: Person {\n        .init(\n            name: \"Lorna,\n            surname: [\"Clare\"],\n            color: Color.blue.opacity(0.6),\n            image: Image(systemName: \"swift\"),\n            character: \"k\"\n            )\n    }\n\n    static var mockArray: [Person ] {\n        [\n           .init(\n               name: \"Valentina,\n               surname: [\"Queenie\"],\n               color: Color.blue.opacity(0.6),\n               image: Image(systemName: \"swift\"),\n               character: \"k\"\n               ),\n           .init(\n               name: \"Lorna,\n               surname: [\"Bettye\"],\n               color: Color.blue.opacity(0.6),\n               image: Image(systemName: \"swift\"),\n               character: \"k\"\n               )\n        ]\n    }\n    #endif\n}\n```\n\n### CodingKeys macro\nUsage of `CodingKeys` without `codingKeyType` param passing generates CodingKeys with `.camelCase`. `CodingKeys` macro works only with stored property types. If you want to set custom coding key to the desired param, use `@CodingKeyProperty(desired_value)`. To ignore desired param from `CodingKeys` enum, use `@CodingKeyIgnored()`.\n```swift\nimport RJSwiftMacros\n\n@CodingKeys()\nclass Car {\n    let modelColor: String\n    @CodingKeyProperty(\"car_model\") let model: String\n    @CodingKeyIgnored() let speed: Int\n\n    init(modelColor: String, model: String, speed: Int) {\n        self.modelColor = modelColor\n        self.model = model\n        self.speed = speed\n    }\n\n    enum CodingKeys: String, CodingKey {\n       case modelColor\n       case model = \"car_model\"\n    }\n}\n```\n\nCodingKeys generation with `.snakeCase`.\n```swift\nimport RJSwiftMacros\n\n@CodingKeys(codingKeyType: .snakeCase)\nstruct University {\n    let name: String\n    let studentCapacity: Int\n    let cars: [String]?\n    var closure: (() -\u003e ())?\n\n    static var students: [String] = []\n    \n    var oldName: String {\n        \"Tbilisi\"\n    }\n    \n    enum CodingKeys: String, CodingKey {\n        case name = \"name\"\n        case studentCapacity = \"student_capacity\"\n        case cars = \"cars\"\n    }\n}\n```\n\n## Requirements\n\n- Swift 5.10 or later\n- macOS 10.15 or later\n- iOS 15 or later\n  \n## Contributing\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n\n\n## Contact\nFor questions or feedback, feel free to reach out to rezojoglidze7@gmail.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezojoglidze%2Frjswiftmacros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frezojoglidze%2Frjswiftmacros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezojoglidze%2Frjswiftmacros/lists"}