Finite state machine for Swift
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Finite state machine for Swift.

If you like the way this is progressing, please star it...

This is very much a work in progress; please check back for progress. If you'd like to see what's coming, take a look at the state.js and state.cs projects.

Swift is a very new language to me so any suggestions via Github issues are very welcome.


  • 2016-04-18: Split runtime code from model code.
  • 2016-04-15: Add element removal code.
  • 2016-04-13: Finish commenting.
  • 2016-04-12: Tidying and comments.
  • 2016-04-08: Added exception handling and starting to tidy and comment code.
  • 2016-04-01: Last of the file refactoring
  • 2016-03-25: Remove ++ and -- operators as they're now deprecated and will be dropped in Swift 3.
  • 2016-03-18: Initial re-factoring into a file per class.
  • 2016-03-18: Well, it's been a long journey, but here is some working code; still a way from RC1 but proves it can be done in Swift.
  • 2016-01-29: Simplify example code; added another visitor.
  • 2016-01-28: Add templated state machine instance into the model; migrate some functions to computed properties.
  • 2016-01-13: Complete the model building code.
  • 2016-01-09: Declare immutable properties of classes with let; extract Element from NamedElement and derive Transition from Element; add transitions to their parent vertex.
  • 2016-01-08: Make NamedElement implement Hashable to be able to use model elements in Sets and as the key to Dictionaries.
  • 2016-01-07: Add guards to transitions.
  • 2016-01-06: Add entry/exit callbacks for states.
  • 2016-01-05: Add convenience init methods to allow direct use of states as vertex parents.
  • 2016-01-04: Add a lazy defaultRegion mehtod to state and stronger example model.
  • 2015-12-11: Add a Guard and Behavior types.
  • 2015-12-09: Building the model structure is underway.