TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2016 |
SPMSupports SPM | ✓ |
Maintained by Brad Hilton.
Allegro
is an advanced Swift reflection utility that allows you to create classes and structs at run-time:
struct Person {
var name: String
var age: Int
var friends: [Person]
}
// Returns fields for Person
let fields = try fieldsForType(Person)
// Constructs Person
let person: Person = try constructType { field in
// return value for field
}
Be aware that every property of the type you’d like to construct must conform to Property
.
You can also build Allegro
using the Swift Package Manager. Just include Allegro
as a package in your dependencies:
.Package(url: "https://github.com/bradhilton/Allegro.git", majorVersion: 1)
Be sure to import the module at the top of your .swift files:
import Allegro
Brad Hilton, [email protected]
Allegro
is available under the MIT license. See the LICENSE file for more info.