### Swift Package Manager Installation Source: https://github.com/hainayanda/dummyable/blob/main/README.md Instructions for installing Dummyable using Swift Package Manager, both via Xcode and directly in Package.swift. ```swift dependencies: [ .package(url: "https://github.com/hainayanda/Dummyable.git", .upToNextMajor(from: "1.1.5")) ] ``` ```swift .target( name: "MyModule", dependencies: ["Dummyable"] ) ``` -------------------------------- ### Enabling Dummy Creation on Structs Source: https://github.com/hainayanda/dummyable/blob/main/README.md Demonstrates how to use the `@Dummyable` macro on structs to enable dummy instance creation. It also shows how to specify a custom initializer using `@DummyableInit`. ```swift @Dummyable struct SomeModel { let title: String var description: String let someType: SomeType func doSomething() { // Do something } } ``` ```swift @Dummyable struct SomeModelWithCustomInit { let title: String var description: String let someType: SomeType @DummyableInit init(title: String, description: String = "", someType: SomeType) { self.title = title self.description = description } func doSomething() { // Do something } } ``` -------------------------------- ### Basic Dummy Instance Creation Source: https://github.com/hainayanda/dummyable/blob/main/README.md Demonstrates how to create dummy instances of basic Swift types and collections using the `dummy(of:)` function. ```swift let intDummy = dummy(of: Int.self) let intDummies = dummy(of: [Int].self, count: 10) ``` -------------------------------- ### Dummyable Class Initialization Source: https://github.com/hainayanda/dummyable/blob/main/README.md Demonstrates how to enable dummy instance creation for a class using the @Dummyable macro and @DummyableInit for custom initializers. It highlights the requirement for associated types to be dummyable. ```swift @Dummyable class SomeModel { let title: String var description: String let someType: SomeType @DummyableInit init(title: String, description: String, someType: SomeType) { self.title = title self.description = description } // SomeType must be marked with @Dummyable, have #Dummy macro declaration, or provided by a `dummy(of:)` global function } ``` -------------------------------- ### Enabling Dummy Creation on Protocols Source: https://github.com/hainayanda/dummyable/blob/main/README.md Illustrates how to use the `@Dummyable` macro on protocols to enable dummy instance creation. It covers creating dummy classes, objects, and class instances. ```swift @Dummyable(.struct) protocol SomeModelProtocol { var title: String { get } var description: String { get set } var someType: SomeType { get } init(title: String, description: String) func doSomething() } ``` ```swift // Tell Dummyable to implement the protocol to a dummy class @Dummyable(.class) protocol SomeModelProtocol { } ``` ```swift // Tell Dummyable the protocol is an object @Dummyable protocol SomeObjectProtocol: AnyObject { } ``` ```swift // Tell Dummyable the protocol is a class instance @Dummyable protocol SomeClassProtocol: class { } ``` -------------------------------- ### Dummy Macro with Generic Parameters Source: https://github.com/hainayanda/dummyable/blob/main/README.md Explains how to use the #Dummy macro with generic types, including specifying generic parameters, adding where clauses for protocol conformance, and setting platform availability. ```swift #Dummy(TypeWithGeneric.self) { TypeWithGeneric() } ``` ```swift // Tell #Dummy to treat the generic parameter at 0 as generic #Dummy(TypeWithGeneric.self, .isGeneric(0)) { TypeWithGeneric() } ``` ```swift #Dummy(TypeWithGeneric.self, .where(0, conform: SomeProtocol.self, (any Equatable).self)) { TypeWithGeneric() } ``` ```swift #Dummy(TypeWithGeneric.self, .availble(.iOS(15.0))) { TypeWithGeneric() } ``` -------------------------------- ### Dummy Instance Creation for Marked Types Source: https://github.com/hainayanda/dummyable/blob/main/README.md Shows how to create dummy instances for types that are marked with the `@Dummyable` macro or have a `#Dummy` macro declaration. ```swift let someDummy = dummy(of: SomeMarkedWithDummyable.self) ``` -------------------------------- ### Dummyable Enum Creation Source: https://github.com/hainayanda/dummyable/blob/main/README.md Shows how to enable dummy instance creation for an enum using the @Dummyable macro. It explains the default behavior of selecting the last case or the one with the least associated value, and how to specify a case with @DummyableCase. ```swift @Dummyable enum SomeEnum { case one case two case three } ``` ```swift @Dummyable enum SomeEnum { @DummyableCase case one case two case three } ``` -------------------------------- ### Dummyable Mechanism Explanation Source: https://github.com/hainayanda/dummyable/blob/main/README.md Details how Dummyable functions by relying on the `dummy(of:)` global function and explains how to resolve compile-time errors when types cannot be automatically created, either by marking them with @Dummyable, using #Dummy, or providing a manual `dummy(of:)` function. ```swift // On the generated code self.title = dummy(of: String.self) ``` ```swift // On the generated code self.someType = dummy(of: SomeType.self) // Default argument value of type 'Any' cannot be converted to type 'SomeType' ``` ```swift func dummy(of type: SomeType.Type) -> SomeType { SomeType() } ``` -------------------------------- ### Dummy Macro for Undefined Types Source: https://github.com/hainayanda/dummyable/blob/main/README.md Illustrates using the #Dummy macro to enable dummy creation for types whose declarations are inaccessible. This includes creating dummies for closures and tuples, and customizing the global dummy function's accessibility with #PublicDummy and #PrivateDummy. ```swift #Dummy(SomeType.self) { SomeType() } ``` ```swift #Dummy((() -> (Int, String)).self) { { (1, "Hello") } } ``` ```swift // Or #PrivateDummy for fileprivate global function #PublicDummy(SomeType.self) { SomeType() } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.