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

Commit

Permalink
Documentation changes + changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Jun 6, 2017
1 parent 6ceb4db commit 31ce737
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 44 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* Since Swift 2 is no longer actively supported, we now consider those templates as "legacy" and cannot guarantee that there won't be issues with the generated code.
[David Jennes](https://github.com/djbe)
[#53](https://github.com/SwiftGen/templates/issues/53)
* The iOS and macOS storyboard templates have been unified into one. The generated code also no longer uses enum cases for scenes but instead uses a generic struct. See the documentation for some examples.
[David Jennes](https://github.com/djbe)
[#57](https://github.com/SwiftGen/templates/issues/57)

### New Features

Expand Down
4 changes: 2 additions & 2 deletions Documentation/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Below is a list of renamed and removed templates, grouped by subcommand. If your
| --- | --- | ------ |
| default | swift2 | |
| lowercase | **deleted** | No longer needed since we prefix classes with their module |
| osx-default | macOS-swift2 | |
| osx-default | **deleted** | Unified with the iOS template, just use `swift2` |
| osx-lowercase | **deleted** | No longer needed since we prefix classes with their module |
| osx-swift3 | macOS-swift3 | |
| osx-swift3 | **deleted** | Unified with the iOS template, just use `swift3` |
| uppercase | **deleted** | No longer needed since we prefix classes with their module |

### Strings ###
Expand Down
27 changes: 7 additions & 20 deletions Documentation/storyboards/swift2.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,19 @@ Note: the generated code may look differently depending on the platform the stor

```swift
enum StoryboardScene {
enum Dependency: String, StoryboardSceneType {
enum Dependency: StoryboardType {
static let storyboardName = "Dependency"

case DependentScene = "Dependent"
static func instantiateDependent() -> UIViewController {
return StoryboardScene.Dependency.DependentScene.viewController()
}
static let Dependent = SceneType<UIViewController>(Dependency.self, identifier: "Dependent")
}
enum Message: String, StoryboardSceneType {
enum Message: StoryboardType {
static let storyboardName = "Message"

case MessagesListScene = "MessagesList"
static func instantiateMessagesList() -> UITableViewController {
guard let vc = StoryboardScene.Message.MessagesListScene.viewController() as? UITableViewController
else {
fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.")
}
return vc
}
static let MessagesList = SceneType<UITableViewController>(Message.self, identifier: "MessagesList")
}
}
enum StoryboardSegue {
enum Message: String, StoryboardSegueType {
enum Message: String, SegueType {
case Embed
case NonCustom
}
Expand All @@ -63,11 +53,8 @@ enum StoryboardSegue {
## Usage example

```swift
// You can instantiate scenes using the generic `viewController()` method:
let vc = StoryboardScene.Dependency.DependentScene.viewController()

// or the `instantiate...()` method (which will cast to the correct type):
let vc2 = StoryboardScene.Message.instantiateMessagesList()
// You can instantiate scenes using the `controller` property:
let vc = StoryboardScene.Dependency.Dependent.controller

// You can perform segues using:
vc.performSegue(StoryboardSegue.Message.Embed)
Expand Down
27 changes: 7 additions & 20 deletions Documentation/storyboards/swift3.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,19 @@ Note: the generated code may look differently depending on the platform the stor

```swift
enum StoryboardScene {
enum Dependency: String, StoryboardSceneType {
enum Dependency: StoryboardType {
static let storyboardName = "Dependency"

case dependentScene = "Dependent"
static func instantiateDependent() -> UIViewController {
return StoryboardScene.Dependency.dependentScene.viewController()
}
static let dependent = SceneType<UIViewController>(storyboard: Dependency.self, identifier: "Dependent")
}
enum Message: String, StoryboardSceneType {
enum Message: StoryboardType {
static let storyboardName = "Message"

case messagesListScene = "MessagesList"
static func instantiateMessagesList() -> UITableViewController {
guard let vc = StoryboardScene.Message.messagesListScene.viewController() as? UITableViewController
else {
fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.")
}
return vc
}
static let messagesList = SceneType<UITableViewController>(storyboard: Message.self, identifier: "MessagesList")
}
}
enum StoryboardSegue {
enum Message: String, StoryboardSegueType {
enum Message: String, SegueType {
case embed
case nonCustom
}
Expand All @@ -62,11 +52,8 @@ enum StoryboardSegue {
## Usage example

```swift
// You can instantiate scenes using the generic `viewController()` method:
let vc = StoryboardScene.Dependency.dependentScene.viewController()

// or the `instantiate...()` method (which will cast to the correct type):
let vc2 = StoryboardScene.Message.instantiateMessagesList()
// You can instantiate scenes using the `controller` property:
let vc = StoryboardScene.Dependency.dependent.controller

// You can perform segues using:
vc.perform(segue: StoryboardSegue.Message.embed)
Expand Down
4 changes: 3 additions & 1 deletion templates/storyboards/swift2.stencil
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

{% if storyboards %}
{% if platform and storyboards %}
{% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
{% set prefix %}{% if isAppKit %}NS{% else %}UI{% endif %}{% endset %}
{% set controller %}{% if isAppKit %}Controller{% else %}ViewController{% endif %}{% endset %}
Expand Down Expand Up @@ -99,6 +99,8 @@ enum {{param.segueEnumName|default:"StoryboardSegue"}} {
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name

private final class BundleToken {}
{% elif storyboards %}
// Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
{% else %}
// No storyboard found
{% endif %}
4 changes: 3 additions & 1 deletion templates/storyboards/swift3.stencil
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

{% if storyboards %}
{% if platform and storyboards %}
{% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
{% set prefix %}{% if isAppKit %}NS{% else %}UI{% endif %}{% endset %}
{% set controller %}{% if isAppKit %}Controller{% else %}ViewController{% endif %}{% endset %}
Expand Down Expand Up @@ -99,6 +99,8 @@ enum {{param.segueEnumName|default:"StoryboardSegue"}} {
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name

private final class BundleToken {}
{% elif storyboards %}
// Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
{% else %}
// No storyboard found
{% endif %}

0 comments on commit 31ce737

Please sign in to comment.