bradhilton / Allegro

Dynamic Type Construction In Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allegro

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.

Installation

CocoaPods

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

Carthage

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

Swift Package Manager

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

Revision History

  • 1.0.0 - Initial Release

Author

Brad Hilton, brad@skyvive.com

License

Allegro is available under the MIT license. See the LICENSE file for more info.

About

Dynamic Type Construction In Swift

License:MIT License


Languages

Language:Swift 96.7%Language:Ruby 2.8%Language:C 0.5%