swift_generator
This gem vends an API to generate swift code programatically. Any number of code elements can be created simultaneously and iteratively.
Installation
Add this line to your application's Gemfile:
gem 'swift_generator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install swift_generator
Usage
Ruby API
# Coming Soon
Command Line Tool
Work on a simple command-line interface has been started to generate Swift code from non-ruby systems.
To invoke the tool:
genswift generate SPECFILE []
or just
genswift SPECFILE []
Some help is availible:
genswift help
genswift help generate
Specfile Format
# Coming Soon
Project Status
The initial use of this gem is by the objective_c_2_swift_assistant gem to generate Swift files.
The current release is functional, but rough. Testing, input validation, and other important quality aspects are missing.
Design and History
This gem started out as a way to generate Swift code for a production application. It was started a few weeks after WWDC 2014.
The design was experiment in a sense. We want to see if it was possible to create a code generator that could have some intelligence about the code it was generating.
Goals
- Preservation of intermediate state information for debugging and extensibility
- High-level constructs for things that matter to developers: Types, Classes, Methods, Properties, ...
- The ability to generate unit tests for the methods it generates. This feature is not yet well documented at this time
- Ability to generate meaningful pure Swift classes (classes not descending from NSObject)
- JSON serialization support for generated Swift classes
Non-Goals
- Code generation speed
- Minimal Memory Footprint
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
- Fork it ( https://github.com/[my-github-username]/swift_generator/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request