Skip to content

Add new Xcode templates #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Binary file added .DS_Store
Binary file not shown.
Binary file added Xcode Templates/.DS_Store
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions Xcode Templates/Business Logic.xctemplate/TemplateInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>Default business logic implementation</string>
<key>Summary</key>
<string>Creates minimum default files and implementation for business logic</string>
<key>SortOrder</key>
<string>30</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>File</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___.swift</string>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Filebase:</string>
<key>Description</key>
<string>The name base of the objects to create</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>FileBase</string>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//

import Foundation

class ___FILEBASENAMEASIDENTIFIER___
{
// MARK: - Property

var output: ___VARIABLE_productName:identifier___InteractorOutput? = nil

// MARK: - Life cycle

init() {

}
}

// MARK: - Presenter Input

extension ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_productName:identifier___InteractorInput
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//

import Foundation

protocol ___FILEBASENAMEASIDENTIFIER___
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//

import Foundation

protocol ___FILEBASENAMEASIDENTIFIER___
{

}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions Xcode Templates/Integration Test.xctemplate/TemplateInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>Default new feature implementation</string>
<key>Summary</key>
<string>Creates minimum default files and implementation for a new feature</string>
<key>SortOrder</key>
<string>30</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>File</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___.swift</string>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Filebase:</string>
<key>Description</key>
<string>The name base of the objects to create</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>FileBase</string>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//

import Foundation

class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_productName:identifier___InteractorInput
{
// MARK: - Variables

private var stateCase: StateCase
weak var output: ___VARIABLE_productName:identifier___InteractorOutput?

// MARK: - init

init(stateCase: StateCase) {
self.stateCase = stateCase
}

// Here you can implement you interactor methods and set up output or other methods depending on your sate case :
//
// func getMethod() {
// switch stateCase {
// case .success :
// scenario_02_success()
// case default:
// scenario_01_error()
// }
// }

// MARK: - SCENARIOS

// Here you can implement you interactor mock methods to call for outputs you want to check for specific scenarios :
//
// private func scenario_01_error() {
// output?.showSuccess()
// }
//
// private func scenario_02_success() {
// output?.showError()
// }
}

/// This code is here to manage state case for different scenarios
/// It should be moved to some other file
public enum StateCase
{
case success
case error
}

public class StateCaseManager
{
public static let shared = StateCaseManager()
public var stateCase: StateCase = .success
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//

// For our testing we made the choice to use [Quick](https://github.com/Quick/Quick) and [Nimble](https://github.com/Quick/Nimble).
// These tools allow us to work efficiently with the GIVEN / WHEN / THEN format.


import XCTest
import Quick
import Nimble

final class ___FILEBASENAMEASIDENTIFIER___: QuickSpec, ExtendedTesting
{
// First describe should give us a context about the functionalities to test
describe("As a user")

/// A struct to give specific state and other static properties if needed to our scenarios
struct TestCase {
var stateCase: StateCase
}

public var viewController: ___VARIABLE_productName:identifier___ViewController?
var storyboardName: String { return "Main" }

/// instantiate all the necessary chain to run our tests
/// - parameter testCase: A struct containing the state for a specific scenario
private func setup(_ testCase: TestCase) {
self.setupViewController()

let interactor = ___VARIABLE_productName:identifier___InteractorMock(stateCase: testCase.stateCase)
let presenter = ___VARIABLE_productName:identifier___Presenter(interactor: interactor)
interactor.output = presenter
presenter.view = self.viewController
self.viewController?.presenter = presenter
self.viewController?.presenter?.viewDidLoad()
}

override func spec() {
// GIVEN should desribe our state, what we use as our `testCase`
describe("GIVEN") {
// WHEN should give us the interaction taking place. This would be what gives us informations about the actions to trigger
context("WHEN") {
beforeEach {
let testCase = TestCase(stateCase: .success)
self.setup(testCase)
}
// THEN gives us what to expect.
it("THEN") {
//expect(self.viewController?.titleLabel?.text).toEventually(equal("Hello world!"))
}
}
}
}


/// This extension is a helper to facilitate storyboard and view controllers manipulation.
/// It should be moved to a separate file

public protocol ExtendedTesting: class {

associatedtype T: UIViewController

var viewController: T? { get set }
var storyboardName: String { get }

func setupViewController()
}

public extension ExtendedTesting {
public var storyboardName: String { return "Main" }

public func setupViewController() {
viewController = UIViewController.fromStoryboard(named: storyboardName, withIdentifier: String(describing: T.self), ofClass: T.self)
viewController?.view.layoutSubviews()
}

}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions Xcode Templates/New Feature.xctemplate/TemplateInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>Default new feature implementation</string>
<key>Summary</key>
<string>Creates minimum default files and implementation for a new feature</string>
<key>SortOrder</key>
<string>30</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>File</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___.swift</string>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Filebase:</string>
<key>Description</key>
<string>The name base of the objects to create</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>FileBase</string>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
</dependencies>
<scenes/>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//

import Foundation
import UIKit

class ___FILEBASENAMEASIDENTIFIER___: UIViewController
{
// MARK: - Property

var presenter: ___VARIABLE_productName:identifier___ViewInterface? = nil

// MARK: - Life cycle

override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning()
{
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

// MARK: - View Interface

extension ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_productName:identifier___ViewInterface
{

}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading