Code Generation Classroom
Learn to use SwiftGen & Sourcery to avoid having to type repetitive, boring code and improve your productivity and your code's type safety & maintenance!
- This classroom expects that you already know how to write Swift 3+ code and have written a few (ideally iOS) applications.
- We'll use Xcode 8.x, but Xcode 9.x should work too
During the classroom, we'll learn how to install SwiftGen and Sourcery, but you are encouraged to download the following ZIP files in advance to have them around in your Download folders and avoid any download latency during the classroom:
During the classroom, we'll use the following websites
- SwiftGen & Sourcery GitHub repositories for their README & documentation
- Sourcery dedicated documentation's website
- Stencil documentation
Walkthrough & Step-Commits
The classroom will consist of multiple steps that we'll go through together
- All the individual steps that we're gonna follow are listed in this repo's wiki.
- Each step is represented by an individual commit in the
stepsbranch of this repository.
Discover the project
- Clone this repository
- The teacher will make a quick tour of the code and app features
- Download, install & discover SwiftGen
- Convert the existing code to use it
- [Bonus] learn how to customize a template
- Download, install & discover Sourcery
- Try our first template to understand basic principles, discover the daemon mode
- Discover & use the
AutoCasestemplate bundled with Sourcery
- Try a third-party
- Create our own template for custom swift code
Bonus : Gyro
We won't probably have time to make a tour of Gyro, but if you're using Realm in your project, you'll likely be very interested in it.
It's again another Code-Generation tool, but this time to generate code (typically your
Realm.Object classes) from
.xcdatamodel, so that you can use Xcode's visual datamodel editor to edit your Realm model with a nice UI.
- Install gyro using
gem install gyro
- Visit Gyro's repository and read the README
- Open one
xcdatamodelfrom the repo (or create your own)
gyroon that xcdatamodel with one of the template (Swift, ObjC, Android) provided and look at the generated code