diff --git a/templates/storyboards-default.stencil b/templates/storyboards-default.stencil index ca97ae9..2022e4e 100644 --- a/templates/storyboards-default.stencil +++ b/templates/storyboards-default.stencil @@ -1,5 +1,6 @@ // Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen +{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}UI{{scene.baseType}}{% endif %}{% endmacro %} import Foundation import UIKit {% for module in modules %} @@ -53,8 +54,8 @@ enum {{sceneEnumName}} { {% if storyboard.scenes %} enum {{storyboardName}}: String, StoryboardSceneType { static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene %}{% if not storyboard.initialScene.isBaseViewController %} - {% set initialSceneClass %}{% if storyboard.initialScene.customClass %}{% if storyboard.initialScene.customModule %}{{storyboard.initialScene.customModule}}.{% endif %}{{storyboard.initialScene.customClass}}{% else %}UI{{storyboard.initialScene.baseType}}{% endif %}{% endset %} + {% if storyboard.initialScene %}{% if storyboard.initialScene.baseType != "ViewController" %} + {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} static func initialViewController() -> {{initialSceneClass}} { guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { @@ -67,25 +68,16 @@ enum {{sceneEnumName}} { {% set sceneID %}{{scene.identifier|swiftIdentifier}}{% endset %} case {{sceneID}}Scene = "{{scene.identifier}}" - {% if not scene.isBaseViewController %} - {% if scene.customClass %} - static func instantiate{{sceneID|snakeToCamelCase}}() -> {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.viewController() as? {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} + {% if scene.baseType != "ViewController" %} + {% set sceneClass %}{% call className scene %}{% endset %} + static func instantiate{{sceneID|snakeToCamelCase}}() -> {{sceneClass}} { + guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.viewController() as? {{sceneClass}} else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}.") + fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") } return vc } {% else %} - static func instantiate{{sceneID|snakeToCamelCase}}() -> UI{{scene.baseType}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.viewController() as? UI{{scene.baseType}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class UI{{scene.baseType}}.") - } - return vc - } - {% endif %} - {% else %} static func instantiate{{sceneID|snakeToCamelCase}}() -> UIViewController { return {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.viewController() } @@ -95,8 +87,8 @@ enum {{sceneEnumName}} { {% else %} enum {{storyboardName}}: StoryboardSceneType { static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene %}{% if not storyboard.initialScene.isBaseViewController %} - {% set initialSceneClass %}{% if storyboard.initialScene.customClass %}{% if storyboard.initialScene.customModule %}{{storyboard.initialScene.customModule}}.{% endif %}{{storyboard.initialScene.customClass}}{% else %}UI{{storyboard.initialScene.baseType}}{% endif %}{% endset %} + {% if storyboard.initialScene %}{% if storyboard.initialScene.baseType != "ViewController" %} + {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} static func initialViewController() -> {{initialSceneClass}} { guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { diff --git a/templates/storyboards-lowercase.stencil b/templates/storyboards-lowercase.stencil index 94c1a34..f7756df 100644 --- a/templates/storyboards-lowercase.stencil +++ b/templates/storyboards-lowercase.stencil @@ -1,5 +1,6 @@ // Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen +{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}UI{{scene.baseType}}{% endif %}{% endmacro %} import Foundation import UIKit {% for module in modules %} @@ -53,8 +54,8 @@ enum {{sceneEnumName}} { {% if storyboard.scenes %} enum {{storyboardName}}: String, StoryboardSceneType { static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene %}{% if not storyboard.initialScene.isBaseViewController %} - {% set initialSceneClass %}{% if storyboard.initialScene.customClass %}{% if storyboard.initialScene.customModule %}{{storyboard.initialScene.customModule}}.{% endif %}{{storyboard.initialScene.customClass}}{% else %}UI{{storyboard.initialScene.baseType}}{% endif %}{% endset %} + {% if storyboard.initialScene %}{% if storyboard.initialScene.baseType != "ViewController" %} + {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} static func initialViewController() -> {{initialSceneClass}} { guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { @@ -67,25 +68,16 @@ enum {{sceneEnumName}} { {% set sceneID %}{{scene.identifier|swiftIdentifier|lowerFirstWord}}{% endset %} case {{sceneID}} = "{{scene.identifier}}" - {% if not scene.isBaseViewController %} - {% if scene.customClass %} - static func {{sceneID}}ViewController() -> {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() as? {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} + {% if scene.baseType != "ViewController" %} + {% set sceneClass %}{% call className scene %}{% endset %} + static func {{sceneID}}ViewController() -> {{sceneClass}} { + guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() as? {{sceneClass}} else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}.") + fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") } return vc } {% else %} - static func {{sceneID}}ViewController() -> UI{{scene.baseType}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() as? UI{{scene.baseType}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class UI{{scene.baseType}}.") - } - return vc - } - {% endif %} - {% else %} static func {{sceneID|lowerFirstWord}}ViewController() -> UIViewController { return {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() } @@ -95,8 +87,8 @@ enum {{sceneEnumName}} { {% else %} enum {{storyboardName}}: StoryboardSceneType { static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene %}{% if not storyboard.initialScene.isBaseViewController %} - {% set initialSceneClass %}{% if storyboard.initialScene.customClass %}{% if storyboard.initialScene.customModule %}{{storyboard.initialScene.customModule}}.{% endif %}{{storyboard.initialScene.customClass}}{% else %}UI{{storyboard.initialScene.baseType}}{% endif %}{% endset %} + {% if storyboard.initialScene %}{% if storyboard.initialScene.baseType != "ViewController" %} + {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} static func initialViewController() -> {{initialSceneClass}} { guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { diff --git a/templates/storyboards-osx-default.stencil b/templates/storyboards-osx-default.stencil index 3695eeb..2839e20 100644 --- a/templates/storyboards-osx-default.stencil +++ b/templates/storyboards-osx-default.stencil @@ -1,5 +1,6 @@ // Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen +{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}NS{{scene.baseType}}{% endif %}{% endmacro %} import Foundation import Cocoa {% for module in modules %} @@ -64,23 +65,14 @@ enum {{sceneEnumName}} { {% set sceneID %}{{scene.identifier|swiftIdentifier}}{% endset %} case {{sceneID}}Scene = "{{scene.identifier}}" - {% if scene.customClass %} - static func instantiate{{sceneID|snakeToCamelCase}}() -> {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} + {% set sceneClass %}{% call className scene %}{% endset %} + static func instantiate{{sceneID|snakeToCamelCase}}() -> {{sceneClass}} { + guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? {{sceneClass}} else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}.") + fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") } return vc } - {% else %} - static func instantiate{{sceneID|snakeToCamelCase}}() -> NS{{scene.baseType}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? NS{{scene.baseType}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class NS{{scene.baseType}}.") - } - return vc - } - {% endif %} {% endfor %} } {% else %} diff --git a/templates/storyboards-osx-lowercase.stencil b/templates/storyboards-osx-lowercase.stencil index 3401cfe..2f5c6d0 100644 --- a/templates/storyboards-osx-lowercase.stencil +++ b/templates/storyboards-osx-lowercase.stencil @@ -1,5 +1,6 @@ // Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen +{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}NS{{scene.baseType}}{% endif %}{% endmacro %} import Foundation import Cocoa {% for module in modules %} @@ -64,23 +65,14 @@ enum {{sceneEnumName}} { {% set sceneID %}{{scene.identifier|swiftIdentifier|lowerFirstWord}}{% endset %} case {{sceneID}}Scene = "{{scene.identifier}}" - {% if scene.customClass %} - static func instantiate{{sceneID||snakeToCamelCase}}() -> {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} + {% set sceneClass %}{% call className scene %}{% endset %} + static func instantiate{{sceneID||snakeToCamelCase}}() -> {{sceneClass}} { + guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? {{sceneClass}} else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}.") + fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") } return vc } - {% else %} - static func instantiate{{sceneID||snakeToCamelCase}}() -> NS{{scene.baseType}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? NS{{scene.baseType}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class NS{{scene.baseType}}.") - } - return vc - } - {% endif %} {% endfor %} } {% else %} diff --git a/templates/storyboards-osx-swift3.stencil b/templates/storyboards-osx-swift3.stencil index f70b9c9..59f9ca8 100644 --- a/templates/storyboards-osx-swift3.stencil +++ b/templates/storyboards-osx-swift3.stencil @@ -1,5 +1,6 @@ // Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen +{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}NS{{scene.baseType}}{% endif %}{% endmacro %} import Foundation import Cocoa {% for module in modules %} @@ -64,23 +65,14 @@ enum {{sceneEnumName}} { {% set sceneID %}{{scene.identifier|swiftIdentifier|snakeToCamelCase|lowerFirstWord}}{% endset %} case {{sceneID}}Scene = "{{scene.identifier}}" - {% if scene.customClass %} - static func instantiate{{sceneID||snakeToCamelCase}}() -> {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} + {% set sceneClass %}{% call className scene %}{% endset %} + static func instantiate{{sceneID||snakeToCamelCase}}() -> {{sceneClass}} { + guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? {{sceneClass}} else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}.") + fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") } return vc } - {% else %} - static func instantiate{{sceneID||snakeToCamelCase}}() -> NS{{scene.baseType}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? NS{{scene.baseType}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class NS{{scene.baseType}}.") - } - return vc - } - {% endif %} {% endfor %} } {% else %} diff --git a/templates/storyboards-swift3.stencil b/templates/storyboards-swift3.stencil index dc5ffed..2342c5b 100644 --- a/templates/storyboards-swift3.stencil +++ b/templates/storyboards-swift3.stencil @@ -1,5 +1,6 @@ // Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen +{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}UI{{scene.baseType}}{% endif %}{% endmacro %} import Foundation import UIKit {% for module in modules %} @@ -53,8 +54,8 @@ enum {{sceneEnumName}} { {% if storyboard.scenes %} enum {{storyboardName}}: String, StoryboardSceneType { static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene %}{% if not storyboard.initialScene.isBaseViewController %} - {% set initialSceneClass %}{% if storyboard.initialScene.customClass %}{% if storyboard.initialScene.customModule %}{{storyboard.initialScene.customModule}}.{% endif %}{{storyboard.initialScene.customClass}}{% else %}UI{{storyboard.initialScene.baseType}}{% endif %}{% endset %} + {% if storyboard.initialScene %}{% if storyboard.initialScene.baseType != "ViewController" %} + {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} static func initialViewController() -> {{initialSceneClass}} { guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { @@ -67,25 +68,16 @@ enum {{sceneEnumName}} { {% set sceneID %}{{scene.identifier|swiftIdentifier|snakeToCamelCase|lowerFirstWord}}{% endset %} case {{sceneID}}Scene = "{{scene.identifier}}" - {% if not scene.isBaseViewController %} - {% if scene.customClass %} - static func instantiate{{sceneID|snakeToCamelCase}}() -> {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.viewController() as? {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} + {% if scene.baseType != "ViewController" %} + {% set sceneClass %}{% call className scene %}{% endset %} + static func instantiate{{sceneID|snakeToCamelCase}}() -> {{sceneClass}} { + guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.viewController() as? {{sceneClass}} else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}.") + fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") } return vc } {% else %} - static func instantiate{{sceneID|snakeToCamelCase}}() -> UI{{scene.baseType}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.viewController() as? UI{{scene.baseType}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class UI{{scene.baseType}}.") - } - return vc - } - {% endif %} - {% else %} static func instantiate{{sceneID|snakeToCamelCase}}() -> UIViewController { return {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.viewController() } @@ -95,8 +87,8 @@ enum {{sceneEnumName}} { {% else %} enum {{storyboardName}}: StoryboardSceneType { static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene %}{% if not storyboard.initialScene.isBaseViewController %} - {% set initialSceneClass %}{% if storyboard.initialScene.customClass %}{% if storyboard.initialScene.customModule %}{{storyboard.initialScene.customModule}}.{% endif %}{{storyboard.initialScene.customClass}}{% else %}UI{{storyboard.initialScene.baseType}}{% endif %}{% endset %} + {% if storyboard.initialScene %}{% if storyboard.initialScene.baseType != "ViewController" %} + {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} static func initialViewController() -> {{initialSceneClass}} { guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { diff --git a/templates/storyboards-uppercase.stencil b/templates/storyboards-uppercase.stencil index b0ace89..fb615cf 100644 --- a/templates/storyboards-uppercase.stencil +++ b/templates/storyboards-uppercase.stencil @@ -1,5 +1,6 @@ // Generated using SwiftGen, by O.Halligon — https://github.com/AliSoftware/SwiftGen +{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}UI{{scene.baseType}}{% endif %}{% endmacro %} import Foundation import UIKit {% for module in modules %} @@ -53,8 +54,8 @@ enum {{sceneEnumName}} { {% if storyboard.scenes %} enum {{storyboardName}}: String, StoryboardSceneType { static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene %}{% if not storyboard.initialScene.isBaseViewController %} - {% set initialSceneClass %}{% if storyboard.initialScene.customClass %}{% if storyboard.initialScene.customModule %}{{storyboard.initialScene.customModule}}.{% endif %}{{storyboard.initialScene.customClass}}{% else %}UI{{storyboard.initialScene.baseType}}{% endif %}{% endset %} + {% if storyboard.initialScene %}{% if storyboard.initialScene.baseType != "ViewController" %} + {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} static func initialViewController() -> {{initialSceneClass}} { guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { @@ -67,25 +68,16 @@ enum {{sceneEnumName}} { {% set sceneID %}{{scene.identifier|swiftIdentifier}}{% endset %} case {{sceneID}} = "{{scene.identifier}}" - {% if not scene.isBaseViewController %} - {% if scene.customClass %} - static func {{sceneID|snakeToCamelCase|lowerFirstWord}}ViewController() -> {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() as? {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}} + {% if scene.baseType != "ViewController" %} + {% set sceneClass %}{% call className scene %}{% endset %} + static func {{sceneID|snakeToCamelCase|lowerFirstWord}}ViewController() -> {{sceneClass}} { + guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() as? {{sceneClass}} else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}.") + fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") } return vc } {% else %} - static func {{sceneID|snakeToCamelCase|lowerFirstWord}}ViewController() -> UI{{scene.baseType}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() as? UI{{scene.baseType}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class UI{{scene.baseType}}.") - } - return vc - } - {% endif %} - {% else %} static func {{sceneID|snakeToCamelCase|lowerFirstWord}}ViewController() -> UIViewController { return {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() } @@ -95,8 +87,8 @@ enum {{sceneEnumName}} { {% else %} enum {{storyboardName}}: StoryboardSceneType { static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene %}{% if not storyboard.initialScene.isBaseViewController %} - {% set initialSceneClass %}{% if storyboard.initialScene.customClass %}{% if storyboard.initialScene.customModule %}{{storyboard.initialScene.customModule}}.{% endif %}{{storyboard.initialScene.customClass}}{% else %}UI{{storyboard.initialScene.baseType}}{% endif %}{% endset %} + {% if storyboard.initialScene %}{% if storyboard.initialScene.baseType != "ViewController" %} + {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} static func initialViewController() -> {{initialSceneClass}} { guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else {