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
.
Allegro
is available through CocoaPods. To install, simply include the following lines in your podfile:
use_frameworks!
pod 'Allegro'
Be sure to import the module at the top of your .swift files:
import Allegro
Allegro
is also available through Carthage. Just add the following to your cartfile:
github "bradhilton/Allegro"
Be sure to import the module at the top of your .swift files:
import Allegro
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
- 1.0.0 - Initial Release
Brad Hilton, [email protected]
Allegro
is available under the MIT license. See the LICENSE file for more info.