Jumpstart your next iOS project with this starter XCode project template showcasing Coordinators.
Based on Andrey Panov's
ApplicationCoordinator tutorial.
Includes full test coverage using Quick
& Nimble, and
swift-snapshot-testing.
This is a ready-to-go XCode project template based on AndreyPanov's ApplicationCoordinator tutorial, and adds:
- Code-based views
- Persistence
- Quick & Nimble specs with 87%+ code coverage
- Swift-snapshot-testing
Just clone the repo, run make install
, then start a new XCode project with the newly available Coordinator Starter Application template.
A lot has been written about Coordinators since the idea was introduced by Khanlou in 2015. They're a piece of the ongoing puzzle of structuring iOS app code in a way that, for one, fixes the otherwise hard to escape problem of massive view controllers. Coordinators refactor out a major responsibility, navigation between view controllers, into its own files.
AndreyPanov's ApplicationCoordinator example, the basis for this template and written for his tutorial write-ups Coordinators Essential Part I and Part II, also includes a Router, which further refactors out the responsibility of pushing, popping, presenting, dismissing, etc., view controllers on a nav stack.
To learn more about Coordinators, and especially the ideas behind this template, consider reading the README and above tutorial posts from the ApplicationCoordinator project, as well as:
- Khanlou's original The Coordinator and Coordinators Redux posts, and his later series on Advanced Coordinators.
- Paul Hudson's (hackingwithswift.com articles How to use the coordinator pattern in iOS apps and Advanced coordinators in iOS.
- XCode (tested with 12.5)
- Clone the repo
git clone https://github.com/tw-space/CoordinatorStarter-XCodeProjectTemplate
- Run the Makefile
make install
- Open XCode, create a new project, and choose the Coordinator Starter, newly listed under Application templates.
-
Optionally choose to:
- Include Quick & Nimble specs
- Include Snapshot Tests
-
(Optional) Set up Quick and Nimble:
- File > Swift Packages > Add Package Dependency...
- Enter in https://github.com/Quick/Quick, then click Next
- Wait, then choose Version: Up to Next Major, then click Next
- Wait, then for the Target, make sure to choose PROJECTNAME-Specs, then click Finish
- Repeat step 1
- Enter in https://github.com/Quick/Nimble, then click Next
- Repeat step 3
- Repeat step 4
-
(Optional) Set up swift-snapshot-testing
- File > Swift Packages > Add Package Dependency...
- Enter in either:
- https://github.com/tw-space/swift-snapshot-testing , which adds missing screen sizes
- https://github.com/pointfreeco/swift-snapshot-testing , the original, which will be better maintained
- Wait, then depending on step 2:
- For the first URL, make sure to choose Branch: Main, then click Next
- For the second URL, choose Version: Up to Next Major, then click Next
- Wait, then for the Target, make sure to choose PROJECTNAME-SnapshotTests, then click Finish
Run make uninstall
in the cloned directory.
Run the app, explore the project files, run the tests, run the snapshots (twice), and start coding!