Tool which allows you easy instaniate View Controllers from storyboards with autocomplete. Forget about copy-pasting Storyboard IDs, and keeping them up to date in your code. Autocomplete will show you only view controllers available by ID on specified storyboard.
Using CocoaPods:
- Add the following line to your Podfile:
pod 'StoryboardIdentification'
- Install pod by running
pod install
- Add run script pharse above the "Compile Sources" section
${PODS_ROOT}/StoryboardIdentification/RefreshStoryboardsData.sh
-
Create empty swift file with name StoryboardIdentifiersUtils.swift at any place of your project as you wish, e.g. at Utils group. This file will be automaticaly updated after each storyboard modification.
-
Build
Simple create/modify existing storyboards and specify storyboard IDs for View Controllers
Build project.
Now you can instantiacte any view controller in next way:
let vc = ViewControllerClass.instantiate(from: .storyboardNameStoryboard(.viewControllerID))
Create Onboarding.storyboard Add new View Controller, you can specify custom class for example SignUpViewController. Specify storyboard ID: SignUpViewControllerID.
Now you can simple call:
let vc = SignUpViewController.instantiate(from: .onboardingStoryboard(.signUpViewControllerID))
If storyboard contains initial view controller, it will be automatically mapped into .initial.
So you can access it by
let vc = OnboardingStartViewController.instantiate(from: .onboardingStoryboard(.initial))
You can get a view controller instance of custom type by specifiing it directly. Or you can simple call UIViewController.instantiate(...) without specifying concrete type. If specified type doesn't match real type of View Controller in storyboard, you'll get fatal error.