### Defining a Simple Swift Class Source: https://github.com/outfoxx/swiftpoet/blob/main/README.md This Swift code defines a basic `Greeter` class with a name property, an initializer, and a `greet` function that returns an `Observable` string using RxSwift. It serves as the target output for the SwiftPoet generation example. ```Swift import RxSwift class Greeter { private let name: String init(name: String) { self.name = name } func greet() -> Observable { return Observable.from("Hello \(name)") } } ``` -------------------------------- ### Generating Swift Code with SwiftPoet (Kotlin) Source: https://github.com/outfoxx/swiftpoet/blob/main/README.md This Kotlin code demonstrates how to use the SwiftPoet API to programmatically generate the `Greeter` Swift class shown in the example. It uses `TypeSpec`, `FunctionSpec`, and `FileSpec` builders to define the class structure, properties, functions, and finally write the output to a string. ```Kotlin val observableTypeName = DeclaredTypeName.typeName("RxSwift.Observable") val testClass = TypeSpec.classBuilder("Greeter") .addProperty("name", STRING, Modifier.PRIVATE) .addFunction( FunctionSpec.constructorBuilder() .addParameter("name", STRING) .addCode("self.name = name\n") .build() ) .addFunction( FunctionSpec.builder("greet") .returns(observableTypeName.parameterizedBy(STRING)) .addCode("return %T.from(\"Hello \\(name)\")\\n", observableTypeName) .build() ) .build() val file = FileSpec.builder("Greeter") .addType(testClass) .build() val out = StringWriter() file.writeTo(out) ``` -------------------------------- ### Preparing Next Development Version (Shell) Source: https://github.com/outfoxx/swiftpoet/blob/main/RELEASING.md Creates a new branch for ongoing development, updates the releaseVersion property in gradle.properties to the $NEXT_VERSION, commits this change, and pushes the branch to the remote GitHub repository. ```shell git checkout -b dev.$NEXT_VERSION sed -i "" \ "s/releaseVersion=.*/releaseVersion=$NEXT_VERSION/g" \ `find . -name "gradle.properties"` git commit -am "Prepare next development version." git push ``` -------------------------------- ### Tagging Release and Pushing to GitHub (Shell) Source: https://github.com/outfoxx/swiftpoet/blob/main/RELEASING.md Creates a new branch for the release, commits changes, creates an annotated tag with the release version, and pushes both the branch and the tag to the remote GitHub repository. ```shell git checkout -b release.$RELEASE_VERSION git commit -am "Prepare for release $RELEASE_VERSION." git tag -a $RELEASE_VERSION -m "Version $RELEASE_VERSION" git push && git push --tags ``` -------------------------------- ### Updating Version Strings in README (Shell) Source: https://github.com/outfoxx/swiftpoet/blob/main/RELEASING.md Uses sed commands to find and replace version strings within README.md files. It updates dependency versions, documentation links, and potentially other version references to the specified $RELEASE_VERSION. ```shell sed -i "" \ "s/'io.outfoxx:\([^\:]*\):[^']*'/'io.outfoxx:\1:$RELEASE_VERSION'/g" \ `find . -name "README.md"` sed -i "" \ "s/outfoxx.github.io\/swiftpoet\/[^\/]*\/\(.*\)/outfoxx.github.io\/swiftpoet\/$RELEASE_VERSION\/\1/g" \ `find . -name "README.md"` sed -i "" \ "s/\\([^<]*\)\<\/version\>/\$RELEASE_VERSION\<\/version\>/g" \ `find . -name "README.md"` ``` -------------------------------- ### Setting Release and Next Development Versions (Shell) Source: https://github.com/outfoxx/swiftpoet/blob/main/RELEASING.md Sets environment variables RELEASE_VERSION and NEXT_VERSION to the desired version numbers for the current release and the subsequent development cycle, respectively. These variables are used in subsequent steps. ```shell export RELEASE_VERSION=X.Y.Z export NEXT_VERSION=X.Y.Z-SNAPSHOT ``` -------------------------------- ### Adding SwiftPoet Dependency (Gradle) Source: https://github.com/outfoxx/swiftpoet/blob/main/README.md This Groovy snippet shows the required `implementation` line to include the SwiftPoet library in a Gradle project's build script (e.g., `build.gradle`). It specifies the group ID, artifact ID, and version. ```Groovy implementation 'io.outfoxx:swiftpoet:1.6.6' ``` -------------------------------- ### Adding SwiftPoet Dependency (Maven) Source: https://github.com/outfoxx/swiftpoet/blob/main/README.md This XML snippet shows the required `` configuration to include the SwiftPoet library in a Maven project's `pom.xml` file. It specifies the group ID, artifact ID, and version. ```XML io.outfoxx swiftpoet 1.6.6 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.