This repository has been archived by the owner on Sep 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from juli1quere/master
Workaround to fix classname issues with storyboards and customModule
- Loading branch information
Showing
17 changed files
with
741 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#if os(iOS) | ||
import UIKit | ||
|
||
public class SLKTextViewController: UIViewController { | ||
} | ||
#elseif os(OSX) | ||
import Cocoa | ||
|
||
class DBPrefsWindowController: NSWindowController { | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
Tests/Expected/Storyboards-iOS/swift2-context-all-ignore-module-need-extra-definitions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen | ||
|
||
// swiftlint:disable sorted_imports | ||
import Foundation | ||
import UIKit | ||
import CustomSegue | ||
import LocationPicker | ||
|
||
// swiftlint:disable file_length | ||
|
||
protocol StoryboardType { | ||
static var storyboardName: String { get } | ||
} | ||
|
||
extension StoryboardType { | ||
static var storyboard: UIStoryboard { | ||
return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) | ||
} | ||
} | ||
|
||
struct SceneType<T: Any> { | ||
let storyboard: StoryboardType.Type | ||
let identifier: String | ||
|
||
var controller: T { | ||
guard let controller = storyboard.storyboard.instantiateViewControllerWithIdentifier(identifier) as? T else { | ||
fatalError("Controller '\(identifier)' is not of the expected class \(T.self).") | ||
} | ||
return controller | ||
} | ||
} | ||
|
||
struct InitialSceneType<T: Any> { | ||
let storyboard: StoryboardType.Type | ||
|
||
var controller: T { | ||
guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else { | ||
fatalError("Controller is not of the expected class \(T.self).") | ||
} | ||
return controller | ||
} | ||
} | ||
|
||
protocol SegueType: RawRepresentable { } | ||
|
||
extension UIViewController { | ||
func performSegue<S: SegueType where S.RawValue == String>(segue: S, sender: AnyObject? = nil) { | ||
performSegueWithIdentifier(segue.rawValue, sender: sender) | ||
} | ||
} | ||
|
||
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name | ||
enum StoryboardScene { | ||
enum AdditionalImport: StoryboardType { | ||
static let storyboardName = "AdditionalImport" | ||
|
||
static let initialScene = InitialSceneType<LocationPicker.LocationPickerViewController>(AdditionalImport.self) | ||
|
||
static let Public = SceneType<SLKTextViewController>(AdditionalImport.self, identifier: "public") | ||
} | ||
enum Anonymous: StoryboardType { | ||
static let storyboardName = "Anonymous" | ||
|
||
static let initialScene = InitialSceneType<UINavigationController>(Anonymous.self) | ||
} | ||
enum Dependency: StoryboardType { | ||
static let storyboardName = "Dependency" | ||
|
||
static let Dependent = SceneType<UIViewController>(Dependency.self, identifier: "Dependent") | ||
} | ||
enum Message: StoryboardType { | ||
static let storyboardName = "Message" | ||
|
||
static let initialScene = InitialSceneType<UIViewController>(Message.self) | ||
|
||
static let Composer = SceneType<UIViewController>(Message.self, identifier: "Composer") | ||
|
||
static let MessagesList = SceneType<UITableViewController>(Message.self, identifier: "MessagesList") | ||
|
||
static let NavCtrl = SceneType<UINavigationController>(Message.self, identifier: "NavCtrl") | ||
|
||
static let URLChooser = SceneType<XXPickerViewController>(Message.self, identifier: "URLChooser") | ||
} | ||
enum Placeholder: StoryboardType { | ||
static let storyboardName = "Placeholder" | ||
|
||
static let Navigation = SceneType<UINavigationController>(Placeholder.self, identifier: "Navigation") | ||
} | ||
enum Wizard: StoryboardType { | ||
static let storyboardName = "Wizard" | ||
|
||
static let initialScene = InitialSceneType<CreateAccViewController>(Wizard.self) | ||
|
||
static let AcceptCGU = SceneType<UIViewController>(Wizard.self, identifier: "Accept-CGU") | ||
|
||
static let CreateAccount = SceneType<CreateAccViewController>(Wizard.self, identifier: "CreateAccount") | ||
|
||
static let Preferences = SceneType<UITableViewController>(Wizard.self, identifier: "Preferences") | ||
|
||
static let ValidatePassword = SceneType<UIViewController>(Wizard.self, identifier: "Validate_Password") | ||
} | ||
} | ||
|
||
enum StoryboardSegue { | ||
enum AdditionalImport: String, SegueType { | ||
case Private = "private" | ||
} | ||
enum Message: String, SegueType { | ||
case CustomBack | ||
case Embed | ||
case NonCustom | ||
case ShowNavCtrl = "Show-NavCtrl" | ||
} | ||
enum Wizard: String, SegueType { | ||
case ShowPassword | ||
} | ||
} | ||
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name | ||
|
||
private final class BundleToken {} |
120 changes: 120 additions & 0 deletions
120
Tests/Expected/Storyboards-iOS/swift3-context-all-ignore-module-need-extra-definitions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen | ||
|
||
// swiftlint:disable sorted_imports | ||
import Foundation | ||
import UIKit | ||
import CustomSegue | ||
import LocationPicker | ||
|
||
// swiftlint:disable file_length | ||
|
||
protocol StoryboardType { | ||
static var storyboardName: String { get } | ||
} | ||
|
||
extension StoryboardType { | ||
static var storyboard: UIStoryboard { | ||
return UIStoryboard(name: self.storyboardName, bundle: Bundle(for: BundleToken.self)) | ||
} | ||
} | ||
|
||
struct SceneType<T: Any> { | ||
let storyboard: StoryboardType.Type | ||
let identifier: String | ||
|
||
func instantiate() -> T { | ||
guard let controller = storyboard.storyboard.instantiateViewController(withIdentifier: identifier) as? T else { | ||
fatalError("ViewController '\(identifier)' is not of the expected class \(T.self).") | ||
} | ||
return controller | ||
} | ||
} | ||
|
||
struct InitialSceneType<T: Any> { | ||
let storyboard: StoryboardType.Type | ||
|
||
func instantiate() -> T { | ||
guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else { | ||
fatalError("ViewController is not of the expected class \(T.self).") | ||
} | ||
return controller | ||
} | ||
} | ||
|
||
protocol SegueType: RawRepresentable { } | ||
|
||
extension UIViewController { | ||
func perform<S: SegueType>(segue: S, sender: Any? = nil) where S.RawValue == String { | ||
performSegue(withIdentifier: segue.rawValue, sender: sender) | ||
} | ||
} | ||
|
||
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name | ||
enum StoryboardScene { | ||
enum AdditionalImport: StoryboardType { | ||
static let storyboardName = "AdditionalImport" | ||
|
||
static let initialScene = InitialSceneType<LocationPicker.LocationPickerViewController>(storyboard: AdditionalImport.self) | ||
|
||
static let `public` = SceneType<SLKTextViewController>(storyboard: AdditionalImport.self, identifier: "public") | ||
} | ||
enum Anonymous: StoryboardType { | ||
static let storyboardName = "Anonymous" | ||
|
||
static let initialScene = InitialSceneType<UINavigationController>(storyboard: Anonymous.self) | ||
} | ||
enum Dependency: StoryboardType { | ||
static let storyboardName = "Dependency" | ||
|
||
static let dependent = SceneType<UIViewController>(storyboard: Dependency.self, identifier: "Dependent") | ||
} | ||
enum Message: StoryboardType { | ||
static let storyboardName = "Message" | ||
|
||
static let initialScene = InitialSceneType<UIViewController>(storyboard: Message.self) | ||
|
||
static let composer = SceneType<UIViewController>(storyboard: Message.self, identifier: "Composer") | ||
|
||
static let messagesList = SceneType<UITableViewController>(storyboard: Message.self, identifier: "MessagesList") | ||
|
||
static let navCtrl = SceneType<UINavigationController>(storyboard: Message.self, identifier: "NavCtrl") | ||
|
||
static let urlChooser = SceneType<XXPickerViewController>(storyboard: Message.self, identifier: "URLChooser") | ||
} | ||
enum Placeholder: StoryboardType { | ||
static let storyboardName = "Placeholder" | ||
|
||
static let navigation = SceneType<UINavigationController>(storyboard: Placeholder.self, identifier: "Navigation") | ||
} | ||
enum Wizard: StoryboardType { | ||
static let storyboardName = "Wizard" | ||
|
||
static let initialScene = InitialSceneType<CreateAccViewController>(storyboard: Wizard.self) | ||
|
||
static let acceptCGU = SceneType<UIViewController>(storyboard: Wizard.self, identifier: "Accept-CGU") | ||
|
||
static let createAccount = SceneType<CreateAccViewController>(storyboard: Wizard.self, identifier: "CreateAccount") | ||
|
||
static let preferences = SceneType<UITableViewController>(storyboard: Wizard.self, identifier: "Preferences") | ||
|
||
static let validatePassword = SceneType<UIViewController>(storyboard: Wizard.self, identifier: "Validate_Password") | ||
} | ||
} | ||
|
||
enum StoryboardSegue { | ||
enum AdditionalImport: String, SegueType { | ||
case `private` | ||
} | ||
enum Message: String, SegueType { | ||
case customBack = "CustomBack" | ||
case embed = "Embed" | ||
case nonCustom = "NonCustom" | ||
case showNavCtrl = "Show-NavCtrl" | ||
} | ||
enum Wizard: String, SegueType { | ||
case showPassword = "ShowPassword" | ||
} | ||
} | ||
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name | ||
|
||
private final class BundleToken {} |
Oops, something went wrong.