Swift is a new object-oriented programming language for iOS and OS X development. To generate Swift code call the code generator with the command line flag −l swift
. To gener- ate a configuration file with all parameters related to the Swift code generation call the code generator as follows once:
java −jar codegen.jar −l swift −gencfg > codegen.cfg
.
The events that can be sent to the machine are defined in a public enumeration.
The generator generates just one Swift class which implements the complete state machine. This has the benefit that your Swift project does not become bloated with all kinds of helper classes. This means that the generated code does not follow the usual state pattern as you might expect (if you are familiar with common design patterns). The reason is that the machine code is completely generated and no hand-coding is involved.
Even if the state machine is fully generated this is usually only a smaller part of your application whereas the lager part is coded manually. For several reasons it is important to clearly separate generated code from non-generated code. Use one of the following possibilities to achieve this.
Please note that the Swift back-end is work-in-progress. If you are interested to test and work with the code generator send me a mail and you will receive the latest beta version. Your feedback and feature requests are highly welcome!