swiftgen
v0.1.4
Published
Generate typesafe Swift code using input TypeScript code.
Readme
SwiftGen
SwiftGen is a tool to convert TypeScript files into Swift code.
Getting Started
Installation
To install the package, run:
npm install -g swiftgenConfiguration
Create a config.json file in your project directory. Example configuration:
{
"inputDir": "path/to/ts-files/root/dir",
"outputDir": "path/to/output/dir",
"outputPrefix": "",
"outputSuffix": ".swift",
"outputFileName": "TypeSwift",
"debug": false
}inputDir: Path to TypeScript files that will be converted to Swift. The search is recursive.outputDir: Path to export the generated Swift file. It will replace any existing files with the same name and path.
Usage
If you want to use a custom configuration file, run SwiftGen with the following command:
swiftgen --config path/to/config.jsonIf no configuration file is specified, SwiftGen will use the default config.json located in the config directory.
Example
Create a
config.jsonfile in your project directory with the desired configuration.Run the tool:
swiftgen --config /path/to/config.jsonOr, if the config.json file is in your project root, simply:
swiftgenCompatible with both relative and absolute paths.
Updating SwiftGen
If you have installed SwiftGen globally and want to update it to the latest version, run:
npm update -g swiftgenAlternatively, you can uninstall and reinstall the package:
npm uninstall -g swiftgen
npm install -g swiftgenAdditional Information
For more details, refer to the TypeSwift project on GitHub.
