Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
Unify the iOS and macOS storyboard templates
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed May 31, 2017
1 parent 8c1e1f2 commit a2c72e1
Show file tree
Hide file tree
Showing 22 changed files with 437 additions and 993 deletions.
87 changes: 0 additions & 87 deletions Documentation/storyboards/macOS-swift2.md

This file was deleted.

86 changes: 0 additions & 86 deletions Documentation/storyboards/macOS-swift3.md

This file was deleted.

3 changes: 2 additions & 1 deletion Documentation/storyboards/swift2.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
## When to use it

- When you need to generate *Swift 2* code
- You want to generate code for UIKit platforms (iOS, tvOS and watchOS)
- **Warning**: Swift 2 is no longer actively supported, so we cannot guarantee that there won't be issues with the generated code.

## Customization
Expand All @@ -24,6 +23,8 @@ You can customize some elements of this template by overriding the following par

## Generated Code

Note: the generated code may look differently depending on the platform the storyboard file is targeting.

**Extract:**

```swift
Expand Down
3 changes: 2 additions & 1 deletion Documentation/storyboards/swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
## When to use it

- When you need to generate *Swift 3* code
- You want to generate code for UIKit platforms (iOS, tvOS and watchOS)

## Customization

Expand All @@ -23,6 +22,8 @@ You can customize some elements of this template by overriding the following par

## Generated Code

Note: the generated code may look differently depending on the platform the storyboard file is targeting.

**Extract:**

```swift
Expand Down
51 changes: 22 additions & 29 deletions Tests/Expected/Storyboards-iOS/swift2-context-all-customname.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ extension StoryboardSceneType {
}

static func initialViewController() -> UIViewController {
guard let vc = storyboard().instantiateInitialViewController() else {
guard let controller = storyboard().instantiateInitialViewController() else {
fatalError("Failed to instantiate initialViewController for \(self.storyboardName)")
}
return vc
return controller
}
}

Expand All @@ -49,29 +49,28 @@ enum XCTStoryboardsScene {
static let storyboardName = "AdditionalImport"

static func initialViewController() -> LocationPicker.LocationPickerViewController {
guard let vc = storyboard().instantiateInitialViewController() as? LocationPicker.LocationPickerViewController else {
guard let controller = storyboard().instantiateInitialViewController() as? LocationPicker.LocationPickerViewController else {
fatalError("Failed to instantiate initialViewController for \(self.storyboardName)")
}
return vc
return controller
}

case PublicScene = "public"
static func instantiatePublic() -> SlackTextViewController.SLKTextViewController {
guard let vc = XCTStoryboardsScene.AdditionalImport.PublicScene.viewController() as? SlackTextViewController.SLKTextViewController
else {
guard let controller = XCTStoryboardsScene.AdditionalImport.PublicScene.viewController() as? SlackTextViewController.SLKTextViewController else {
fatalError("ViewController 'public' is not of the expected class SlackTextViewController.SLKTextViewController.")
}
return vc
return controller
}
}
enum Anonymous: StoryboardSceneType {
static let storyboardName = "Anonymous"

static func initialViewController() -> UINavigationController {
guard let vc = storyboard().instantiateInitialViewController() as? UINavigationController else {
guard let controller = storyboard().instantiateInitialViewController() as? UINavigationController else {
fatalError("Failed to instantiate initialViewController for \(self.storyboardName)")
}
return vc
return controller
}
}
enum Dependency: String, StoryboardSceneType {
Expand All @@ -92,51 +91,47 @@ enum XCTStoryboardsScene {

case MessagesListScene = "MessagesList"
static func instantiateMessagesList() -> UITableViewController {
guard let vc = XCTStoryboardsScene.Message.MessagesListScene.viewController() as? UITableViewController
else {
guard let controller = XCTStoryboardsScene.Message.MessagesListScene.viewController() as? UITableViewController else {
fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.")
}
return vc
return controller
}

case NavCtrlScene = "NavCtrl"
static func instantiateNavCtrl() -> UINavigationController {
guard let vc = XCTStoryboardsScene.Message.NavCtrlScene.viewController() as? UINavigationController
else {
guard let controller = XCTStoryboardsScene.Message.NavCtrlScene.viewController() as? UINavigationController else {
fatalError("ViewController 'NavCtrl' is not of the expected class UINavigationController.")
}
return vc
return controller
}

case URLChooserScene = "URLChooser"
static func instantiateURLChooser() -> XXPickerViewController {
guard let vc = XCTStoryboardsScene.Message.URLChooserScene.viewController() as? XXPickerViewController
else {
guard let controller = XCTStoryboardsScene.Message.URLChooserScene.viewController() as? XXPickerViewController else {
fatalError("ViewController 'URLChooser' is not of the expected class XXPickerViewController.")
}
return vc
return controller
}
}
enum Placeholder: String, StoryboardSceneType {
static let storyboardName = "Placeholder"

case NavigationScene = "Navigation"
static func instantiateNavigation() -> UINavigationController {
guard let vc = XCTStoryboardsScene.Placeholder.NavigationScene.viewController() as? UINavigationController
else {
guard let controller = XCTStoryboardsScene.Placeholder.NavigationScene.viewController() as? UINavigationController else {
fatalError("ViewController 'Navigation' is not of the expected class UINavigationController.")
}
return vc
return controller
}
}
enum Wizard: String, StoryboardSceneType {
static let storyboardName = "Wizard"

static func initialViewController() -> CreateAccViewController {
guard let vc = storyboard().instantiateInitialViewController() as? CreateAccViewController else {
guard let controller = storyboard().instantiateInitialViewController() as? CreateAccViewController else {
fatalError("Failed to instantiate initialViewController for \(self.storyboardName)")
}
return vc
return controller
}

case Accept_CGUScene = "Accept-CGU"
Expand All @@ -146,20 +141,18 @@ enum XCTStoryboardsScene {

case CreateAccountScene = "CreateAccount"
static func instantiateCreateAccount() -> CreateAccViewController {
guard let vc = XCTStoryboardsScene.Wizard.CreateAccountScene.viewController() as? CreateAccViewController
else {
guard let controller = XCTStoryboardsScene.Wizard.CreateAccountScene.viewController() as? CreateAccViewController else {
fatalError("ViewController 'CreateAccount' is not of the expected class CreateAccViewController.")
}
return vc
return controller
}

case PreferencesScene = "Preferences"
static func instantiatePreferences() -> UITableViewController {
guard let vc = XCTStoryboardsScene.Wizard.PreferencesScene.viewController() as? UITableViewController
else {
guard let controller = XCTStoryboardsScene.Wizard.PreferencesScene.viewController() as? UITableViewController else {
fatalError("ViewController 'Preferences' is not of the expected class UITableViewController.")
}
return vc
return controller
}

case Validate_PasswordScene = "Validate_Password"
Expand Down
Loading

0 comments on commit a2c72e1

Please sign in to comment.