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

Missing storyboards module ignore #27

Merged
merged 6 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Fixed `swiftlint` warnings in generated color extensions.
[Roman Laitarenko](https://github.com/evil159)
[#32](https://github.com/SwiftGen/templates/pull/32)
* The storyboards macOS swift3 template was missing the "current target" module ignore code.
[@djbe](https://github.com/djbe)
[#27](https://github.com/SwiftGen/templates/issues/27)

### Breaking Changes

Expand Down
6 changes: 3 additions & 3 deletions Contexts/Storyboards-macOS/all.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<dict>
<key>extraImports</key>
<array>
<string>FadeSegue</string>
<string>PrefsWindowController</string>
</array>
<key>modules</key>
<array>
<string>FadeSegue</string>
<string>PrefsWindowController</string>
</array>
<key>param</key>
Expand Down Expand Up @@ -159,9 +161,7 @@
</dict>
<dict>
<key>customClass</key>
<string></string>
<key>customModule</key>
<string></string>
<string>FadeSegue</string>
<key>identifier</key>
<string>public</string>
</dict>
Expand Down
6 changes: 3 additions & 3 deletions Contexts/Storyboards-macOS/customname.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<dict>
<key>extraImports</key>
<array>
<string>FadeSegue</string>
<string>PrefsWindowController</string>
</array>
<key>modules</key>
<array>
<string>FadeSegue</string>
<string>PrefsWindowController</string>
</array>
<key>param</key>
Expand Down Expand Up @@ -159,9 +161,7 @@
</dict>
<dict>
<key>customClass</key>
<string></string>
<key>customModule</key>
<string></string>
<string>FadeSegue</string>
<key>identifier</key>
<string>public</string>
</dict>
Expand Down
12 changes: 7 additions & 5 deletions Contexts/Storyboards-macOS/messages.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
<plist version="1.0">
<dict>
<key>extraImports</key>
<array/>
<array>
<string>FadeSegue</string>
</array>
<key>modules</key>
<array/>
<array>
<string>FadeSegue</string>
</array>
<key>param</key>
<dict>
<key>sceneEnumName</key>
Expand Down Expand Up @@ -113,9 +117,7 @@
</dict>
<dict>
<key>customClass</key>
<string></string>
<key>customModule</key>
<string></string>
<string>FadeSegue</string>
<key>identifier</key>
<string>public</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Fixtures/Storyboards-macOS/Message.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<segue destination="F1C-uo-ozY" kind="custom" identifier="public" id="and-Oo-071"/>
<segue destination="F1C-uo-ozY" kind="custom" identifier="public" customClass="FadeSegue" customModule="FadeSegue" id="and-Oo-071"/>
</connections>
</textField>
</subviews>
Expand Down
4 changes: 4 additions & 0 deletions Fixtures/stub-env/Modules/FadeSegue.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import AppKit

public class FadeSegue: NSStoryboardSegue {
}
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace :output do
Utils.print_header 'Compile output modules'

# macOS
modules = ['PrefsWindowController']
modules = ['FadeSegue', 'PrefsWindowController']
modules.each do |m|
Utils.print_info "Compiling module #{m}… (macos)"
compile_module(m, :macosx, task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Foundation
import Cocoa
import FadeSegue
import PrefsWindowController

// swiftlint:disable file_length
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen

import Foundation
import Cocoa
import PrefsWindowController

// swiftlint:disable file_length
// swiftlint:disable line_length
// swiftlint:disable type_body_length

protocol StoryboardSceneType {
static var storyboardName: String { get }
}

extension StoryboardSceneType {
static func storyboard() -> NSStoryboard {
return NSStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self))
}

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

extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String {
func controller() -> AnyObject {
return Self.storyboard().instantiateControllerWithIdentifier(self.rawValue)
}
static func controller(identifier: Self) -> AnyObject {
return identifier.controller()
}
}

protocol StoryboardSegueType: RawRepresentable { }

extension NSWindowController {
func performSegue<S: StoryboardSegueType where S.RawValue == String>(segue: S, sender: AnyObject? = nil) {
performSegueWithIdentifier(segue.rawValue, sender: sender)
}
}

extension NSViewController {
func performSegue<S: StoryboardSegueType where S.RawValue == String>(segue: S, sender: AnyObject? = nil) {
performSegueWithIdentifier(segue.rawValue, sender: sender)
}
}

enum StoryboardScene {
enum AdditionalImport: String, StoryboardSceneType {
static let storyboardName = "AdditionalImport"

case PrivateScene = "private"
static func instantiatePrivate() -> PrefsWindowController.DBPrefsWindowController {
guard let vc = StoryboardScene.AdditionalImport.PrivateScene.controller() as? PrefsWindowController.DBPrefsWindowController
else {
fatalError("ViewController 'private' is not of the expected class PrefsWindowController.DBPrefsWindowController.")
}
return vc
}
}
enum Anonymous: StoryboardSceneType {
static let storyboardName = "Anonymous"
}
enum Dependency: String, StoryboardSceneType {
static let storyboardName = "Dependency"

case DependentScene = "Dependent"
static func instantiateDependent() -> NSViewController {
guard let vc = StoryboardScene.Dependency.DependentScene.controller() as? NSViewController
else {
fatalError("ViewController 'Dependent' is not of the expected class NSViewController.")
}
return vc
}
}
enum Message: String, StoryboardSceneType {
static let storyboardName = "Message"

case MessageDetailsScene = "MessageDetails"
static func instantiateMessageDetails() -> NSViewController {
guard let vc = StoryboardScene.Message.MessageDetailsScene.controller() as? NSViewController
else {
fatalError("ViewController 'MessageDetails' is not of the expected class NSViewController.")
}
return vc
}

case MessageListScene = "MessageList"
static func instantiateMessageList() -> NSViewController {
guard let vc = StoryboardScene.Message.MessageListScene.controller() as? NSViewController
else {
fatalError("ViewController 'MessageList' is not of the expected class NSViewController.")
}
return vc
}

case MessageListFooterScene = "MessageListFooter"
static func instantiateMessageListFooter() -> NSViewController {
guard let vc = StoryboardScene.Message.MessageListFooterScene.controller() as? NSViewController
else {
fatalError("ViewController 'MessageListFooter' is not of the expected class NSViewController.")
}
return vc
}

case MessagesTabScene = "MessagesTab"
static func instantiateMessagesTab() -> CustomTabViewController {
guard let vc = StoryboardScene.Message.MessagesTabScene.controller() as? CustomTabViewController
else {
fatalError("ViewController 'MessagesTab' is not of the expected class CustomTabViewController.")
}
return vc
}

case SplitMessagesScene = "SplitMessages"
static func instantiateSplitMessages() -> NSSplitViewController {
guard let vc = StoryboardScene.Message.SplitMessagesScene.controller() as? NSSplitViewController
else {
fatalError("ViewController 'SplitMessages' is not of the expected class NSSplitViewController.")
}
return vc
}

case WindowCtrlScene = "WindowCtrl"
static func instantiateWindowCtrl() -> NSWindowController {
guard let vc = StoryboardScene.Message.WindowCtrlScene.controller() as? NSWindowController
else {
fatalError("ViewController 'WindowCtrl' is not of the expected class NSWindowController.")
}
return vc
}
}
enum Placeholder: String, StoryboardSceneType {
static let storyboardName = "Placeholder"

case DependentScene = "Dependent"
static func instantiateDependent() -> NSControllerPlaceholder {
guard let vc = StoryboardScene.Placeholder.DependentScene.controller() as? NSControllerPlaceholder
else {
fatalError("ViewController 'Dependent' is not of the expected class NSControllerPlaceholder.")
}
return vc
}

case WindowScene = "Window"
static func instantiateWindow() -> NSWindowController {
guard let vc = StoryboardScene.Placeholder.WindowScene.controller() as? NSWindowController
else {
fatalError("ViewController 'Window' is not of the expected class NSWindowController.")
}
return vc
}
}
}

enum StoryboardSegue {
enum Message: String, StoryboardSegueType {
case Embed
case Modal
case Popover
case Sheet
case Show
case Public = "public"
}
}

private final class BundleToken {}
1 change: 1 addition & 0 deletions Tests/Expected/Storyboards-macOS/default-context-all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Foundation
import Cocoa
import FadeSegue
import PrefsWindowController

// swiftlint:disable file_length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Foundation
import Cocoa
import FadeSegue
import PrefsWindowController

// swiftlint:disable file_length
Expand Down
Loading