Generic State Machine in Swift StateMachine/StateMachine.swift is the generally useful file here. The rest is just an example use. For details, see my blog post.