All Projects → outfoxx → Swiftpoet

outfoxx / Swiftpoet

Licence: apache-2.0
Kotlin and Java API for generating .swift source files.

Programming Languages

swift
15916 projects
kotlin
9241 projects

Labels

Projects that are alternatives of or similar to Swiftpoet

Net Core Docx Html To Pdf Converter
.NET Core library to create custom reports based on Word docx or HTML documents and convert to PDF
Stars: ✭ 133 (-7.64%)
Mutual labels:  generator
Typegraphql Prisma
Prisma 2 generator to emit TypeGraphQL types and CRUD resolvers from your Prisma 2 schema
Stars: ✭ 137 (-4.86%)
Mutual labels:  generator
Gh Actions Yaml Generator
Ghygen is a GitHub Actions configurator for your Laravel Application.
Stars: ✭ 142 (-1.39%)
Mutual labels:  generator
Gk
Go-Kit Genetator
Stars: ✭ 136 (-5.56%)
Mutual labels:  generator
Generator Jekyll Starter Kit
🚀 Jekyll Progressive Web App Generator.
Stars: ✭ 139 (-3.47%)
Mutual labels:  generator
Nuxt Generate Cluster
Multi-threaded generator command for nuxt.js
Stars: ✭ 140 (-2.78%)
Mutual labels:  generator
Sw2dts
Generates TypeScript definition file(d.ts) from swagger.json for edge cases.
Stars: ✭ 132 (-8.33%)
Mutual labels:  generator
Genmon
Generac Generator Monitoring using a Raspberry Pi and WiFi
Stars: ✭ 143 (-0.69%)
Mutual labels:  generator
Umldoclet
Automatically generate PlantUML diagrams in javadoc
Stars: ✭ 138 (-4.17%)
Mutual labels:  generator
Puppet Retrospec
The only tool you need to generate puppet code, tests, modules, facts, types, providers, data and everything else.
Stars: ✭ 141 (-2.08%)
Mutual labels:  generator
Auto Youtube Subscription Playlist 2
Script automatically adds videos to playlists from Youtube channels and/or subscriptions (Youtube Collections alternative).
Stars: ✭ 136 (-5.56%)
Mutual labels:  generator
Automatic Gatsbyjs App Landing Page
Automatic GatsbyJS App Landing Page - Automatically generate iOS app landing page using GatsbyJS
Stars: ✭ 137 (-4.86%)
Mutual labels:  generator
Gofakeit
Random fake data generator written in go
Stars: ✭ 2,193 (+1422.92%)
Mutual labels:  generator
Toml To Go
Translates TOML into a Go type in your browser instantly
Stars: ✭ 134 (-6.94%)
Mutual labels:  generator
Gf Cli
GoFrame Command Line Interface, which is your helpmate for building GoFrame application with convenience.
Stars: ✭ 143 (-0.69%)
Mutual labels:  generator
Rubico
[a]synchronous functional programming
Stars: ✭ 133 (-7.64%)
Mutual labels:  generator
Github Contribution Stats
Dynamically generated Github Contribution Stats. 📈 📆
Stars: ✭ 139 (-3.47%)
Mutual labels:  generator
App Privacy Policy Generator
A simple web app to generate a generic privacy policy for your Android/iOS apps
Stars: ✭ 2,278 (+1481.94%)
Mutual labels:  generator
Tropical Fish
Pragmatic 风格的 Java EE 后端开发脚手架,开箱即用。基于 SpringBoot,技术选型采用主流的框架(Mybatis-Plus,Redisson,Xxl-job,Swagger)。项目特点:自定义查询语法, 可以自由组装查询条件查询数据,配合代码生成模块,提高研发效率;自定义 service 方法级别的文档生成规则,在业务方法增加必要的注解,可生成方法调用树,快速把握复杂代码业务逻辑。
Stars: ✭ 142 (-1.39%)
Mutual labels:  generator
Project Webcube
Continuously updated JS infrastructure for modern web dev
Stars: ✭ 141 (-2.08%)
Mutual labels:  generator

SwiftPoet

GitHub Workflow Status Maven Central Sonatype Nexus (Snapshots) codebeat badge

SwiftPoet is a Kotlin and Java API for generating .swift source files.

Source file generation can be useful when doing things such as annotation processing or interacting with metadata files (e.g., database schemas, protocol formats). By generating code, you eliminate the need to write boilerplate while also keeping a single source of truth for the metadata.

Example

Here's a HelloWorld file:

import RxSwift


class Greeter {

  private let name: String

  init(name: String) {
    self.name = name
  }

  func greet() -> Observable<String> {
    return Observable.from("Hello \(name)")
  }

}

And this is the code to generate it with SwiftPoet:

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)

The KDoc catalogs the complete SwiftPoet API, which is inspired by JavaPoet.

Download

Download the latest .jar or depend via Maven:

<dependency>
  <groupId>io.outfoxx</groupId>
  <artifactId>swiftpoet</artifactId>
  <version>1.1.0</version>
</dependency>

or Gradle:

compile 'io.outfoxx:swiftpoet:1.1.0'

Snapshots of the development version are available in Sonatype's snapshots repository.

License

Copyright 2017 Outfox, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].