Skip to content

Commit

Permalink
Upgrade SwiftGen
Browse files Browse the repository at this point in the history
  • Loading branch information
keeshux committed Oct 28, 2018
1 parent 474105d commit 0d49d1a
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 251 deletions.
75 changes: 75 additions & 0 deletions Passepartout-iOS/Global/SwiftGen+Scenes.swift
@@ -0,0 +1,75 @@
// swiftlint:disable all
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

// swiftlint:disable sorted_imports
import Foundation
import UIKit

// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length

// MARK: - Storyboard Scenes

// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
internal enum StoryboardScene {
internal enum Main: StoryboardType {
internal static let storyboardName = "Main"

internal static let initialScene = InitialSceneType<UIKit.UISplitViewController>(storyboard: Main.self)

internal static let accountIdentifier = SceneType<AccountViewController>(storyboard: Main.self, identifier: "AccountIdentifier")

internal static let configurationIdentifier = SceneType<ConfigurationViewController>(storyboard: Main.self, identifier: "ConfigurationIdentifier")

internal static let serviceIdentifier = SceneType<UIKit.UINavigationController>(storyboard: Main.self, identifier: "ServiceIdentifier")
}
internal enum Organizer: StoryboardType {
internal static let storyboardName = "Organizer"

internal static let initialScene = InitialSceneType<UIKit.UINavigationController>(storyboard: Organizer.self)

internal static let provider = SceneType<UIKit.UINavigationController>(storyboard: Organizer.self, identifier: "Provider")

internal static let wizardHostIdentifier = SceneType<UIKit.UINavigationController>(storyboard: Organizer.self, identifier: "WizardHostIdentifier")
}
}
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name

// MARK: - Implementation Details

internal protocol StoryboardType {
static var storyboardName: String { get }
}

internal extension StoryboardType {
static var storyboard: UIStoryboard {
let name = self.storyboardName
return UIStoryboard(name: name, bundle: Bundle(for: BundleToken.self))
}
}

internal struct SceneType<T: UIViewController> {
internal let storyboard: StoryboardType.Type
internal let identifier: String

internal func instantiate() -> T {
let identifier = self.identifier
guard let controller = storyboard.storyboard.instantiateViewController(withIdentifier: identifier) as? T else {
fatalError("ViewController '\(identifier)' is not of the expected class \(T.self).")
}
return controller
}
}

internal struct InitialSceneType<T: UIViewController> {
internal let storyboard: StoryboardType.Type

internal func instantiate() -> T {
guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else {
fatalError("ViewController is not of the expected class \(T.self).")
}
return controller
}
}

private final class BundleToken {}
54 changes: 54 additions & 0 deletions Passepartout-iOS/Global/SwiftGen+Segues.swift
@@ -0,0 +1,54 @@
// swiftlint:disable all
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

// swiftlint:disable sorted_imports
import Foundation
import UIKit

// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length

// MARK: - Storyboard Segues

// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
internal enum StoryboardSegue {
internal enum Main: String, SegueType {
case accountSegueIdentifier = "AccountSegueIdentifier"
case debugLogSegueIdentifier = "DebugLogSegueIdentifier"
case endpointSegueIdentifier = "EndpointSegueIdentifier"
case hostParametersSegueIdentifier = "HostParametersSegueIdentifier"
case providerPoolSegueIdentifier = "ProviderPoolSegueIdentifier"
case providerPresetSegueIdentifier = "ProviderPresetSegueIdentifier"
}
internal enum Organizer: String, SegueType {
case aboutSegueIdentifier = "AboutSegueIdentifier"
case addProviderSegueIdentifier = "AddProviderSegueIdentifier"
case creditsSegueIdentifier = "CreditsSegueIdentifier"
case disclaimerSegueIdentifier = "DisclaimerSegueIdentifier"
case importHostSegueIdentifier = "ImportHostSegueIdentifier"
case selectProfileSegueIdentifier = "SelectProfileSegueIdentifier"
case showImportedHostsSegueIdentifier = "ShowImportedHostsSegueIdentifier"
case versionSegueIdentifier = "VersionSegueIdentifier"
}
}
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name

// MARK: - Implementation Details

internal protocol SegueType: RawRepresentable {}

internal extension UIViewController {
func perform<S: SegueType>(segue: S, sender: Any? = nil) where S.RawValue == String {
let identifier = segue.rawValue
performSegue(withIdentifier: identifier, sender: sender)
}
}

internal extension SegueType where RawValue == String {
init?(_ segue: UIStoryboardSegue) {
guard let identifier = segue.identifier else { return nil }
self.init(rawValue: identifier)
}
}

private final class BundleToken {}
101 changes: 0 additions & 101 deletions Passepartout-iOS/Global/SwiftGen+Storyboards.swift

This file was deleted.

12 changes: 8 additions & 4 deletions Passepartout.xcodeproj/project.pbxproj
Expand Up @@ -9,7 +9,7 @@
/* Begin PBXBuildFile section */
0E05C5D420D1645F006EE732 /* FieldTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E05C5CE20D139AF006EE732 /* FieldTableViewCell.swift */; };
0E05C5D520D1645F006EE732 /* SettingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED824CD20D12DBE00F2FE9E /* SettingTableViewCell.swift */; };
0E05C5D620D1645F006EE732 /* SwiftGen+Storyboards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DE320C89028004C739C /* SwiftGen+Storyboards.swift */; };
0E05C5D620D1645F006EE732 /* SwiftGen+Scenes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DE320C89028004C739C /* SwiftGen+Scenes.swift */; };
0E05C5D720D1645F006EE732 /* ToggleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED824C920D12B8700F2FE9E /* ToggleTableViewCell.swift */; };
0E05C5DC20D198B9006EE732 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0E05C5DF20D198B9006EE732 /* Localizable.strings */; };
0E05C5E420D1993C006EE732 /* SwiftGen+Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E05C5E320D1993C006EE732 /* SwiftGen+Strings.swift */; };
Expand Down Expand Up @@ -85,6 +85,7 @@
0EDE8DE720C93945004C739C /* Credentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DE620C93945004C739C /* Credentials.swift */; };
0EDE8DEE20C93E4C004C739C /* GroupConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DED20C93E4C004C739C /* GroupConstants.swift */; };
0EE3BBB2215ED3A900F30952 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */; };
0EF56BBB2185AC8500B0C8AB /* SwiftGen+Segues.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF56BBA2185AC8500B0C8AB /* SwiftGen+Segues.swift */; };
0EF5CF252141CE58004FF1BD /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5CF242141CE58004FF1BD /* HUD.swift */; };
0EF5CF292141F31F004FF1BD /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7ED20D539A0002221FF /* Utils.swift */; };
0EFD943E215BE10800529B64 /* IssueReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFD943D215BE10800529B64 /* IssueReporter.swift */; };
Expand Down Expand Up @@ -208,10 +209,11 @@
0EDE8DC520C86910004C739C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0EDE8DD220C86978004C739C /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; };
0EDE8DE220C86A13004C739C /* Passepartout.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Passepartout.entitlements; sourceTree = "<group>"; };
0EDE8DE320C89028004C739C /* SwiftGen+Storyboards.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwiftGen+Storyboards.swift"; sourceTree = "<group>"; };
0EDE8DE320C89028004C739C /* SwiftGen+Scenes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwiftGen+Scenes.swift"; sourceTree = "<group>"; };
0EDE8DE620C93945004C739C /* Credentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Credentials.swift; sourceTree = "<group>"; };
0EDE8DED20C93E4C004C739C /* GroupConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupConstants.swift; sourceTree = "<group>"; };
0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
0EF56BBA2185AC8500B0C8AB /* SwiftGen+Segues.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwiftGen+Segues.swift"; sourceTree = "<group>"; };
0EF5CF242141CE58004FF1BD /* HUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = "<group>"; };
0EFD943D215BE10800529B64 /* IssueReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueReporter.swift; sourceTree = "<group>"; };
0EFD943F215BED8E00529B64 /* LabelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -441,7 +443,8 @@
0E4FD7F020D58618002221FF /* Macros.swift */,
0ED38AE9214054A50004D387 /* OptionViewController.swift */,
0EA068F3218475F800C320AD /* ParsedFile+Alerts.swift */,
0EDE8DE320C89028004C739C /* SwiftGen+Storyboards.swift */,
0EDE8DE320C89028004C739C /* SwiftGen+Scenes.swift */,
0EF56BBA2185AC8500B0C8AB /* SwiftGen+Segues.swift */,
0E05C61C20D27C82006EE732 /* Theme.swift */,
0ECEE44F20E1182E00A6BB43 /* Theme+Cells.swift */,
0E2B493F20FCFF990094784C /* Theme+Titles.swift */,
Expand Down Expand Up @@ -827,11 +830,12 @@
0E5E5DE2215119DD00E318A3 /* VPNConfiguration.swift in Sources */,
0EBE3AA0213DC1A100BFA2F5 /* ConnectionProfile.swift in Sources */,
0E1066C920E0F84A004F98B7 /* Cells.swift in Sources */,
0EF56BBB2185AC8500B0C8AB /* SwiftGen+Segues.swift in Sources */,
0EBE3AA6213DC1B000BFA2F5 /* ProviderConnectionProfile.swift in Sources */,
0E3DA371215CB5BF00B40FC9 /* VersionViewController.swift in Sources */,
0EBBE8F52182361800106008 /* ConnectionService+Migration.swift in Sources */,
0E39BCF3214DA9310035E9DE /* AppConstants.swift in Sources */,
0E05C5D620D1645F006EE732 /* SwiftGen+Storyboards.swift in Sources */,
0E05C5D620D1645F006EE732 /* SwiftGen+Scenes.swift in Sources */,
0E2B494220FD16540094784C /* TransientStore.swift in Sources */,
0E89DFC5213DF7AE00741BA1 /* Preferences.swift in Sources */,
0E6BE13A20CFB76800A6DD36 /* ApplicationError.swift in Sources */,
Expand Down

0 comments on commit 0d49d1a

Please sign in to comment.