File Templates & Project Templates

XcodeTemplates

File Templates & Project Templates


文件模板

  • 系统文件模板路径(Xcode7):

    /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates

系统文件模板路径EZ.xctemplate 是我放进入的文件模板(其实只要复制 Cocoa Touch Class.xctemplate模板修改定制成自己的模板),你只要复制EZ.xctemplate到系统文件模板路径下就可以直接使用了。

EZ.xctemplate 文件夹下的EZViewControllerObjective-C,EZViewControllerXibObjective-C,EZViewControllerSwift,EZViewControllerXIBSwift是我增加的文件夹,

UIViewControllerObjective-C,UIViewControllerXIBObjective-C,UIViewControllerSwift,UIViewControllerXIBSwift文件夹做了定制修改。

TemplateIcon.png,[email protected],TemplateInfo.plist也做了相应的修改,其它暂时没有定制,

效果如下: 自定义文件模板效果EZViewControllerObjective-C,EZViewControllerXibObjective-C,EZViewControllerSwift,EZViewControllerXIBSwift 文件夹命名规则是:类名+Objective-C/Swift 如果文件夹下有xib文件,在Objective-C/Swift前加Xib

TemplateIcon.png和[email protected]是模板的icon,大小48*48和96*96

TemplateInfo.plist是模板的配置文件: 模板配置文件1 模板配置文件2 模板配置文件3

Options中得Item0、1、2、3对应下图四个选项: 模板配置文件3

模板代码例子(EZ.xctemplate/EZViewControllerSwift/FILEBASENAME.swift):

//
//  ___FILENAME___
//  ___PROJECTNAME___
//
//  Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//

import UIKit

class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ {

// MARK: - Life cycle
required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}


override func awakeFromNib() {
    super.awakeFromNib()
}

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
    super.init(nibName: nil, bundle: nil)
}

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
}

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
}

override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)
}

override func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated)
}

override func viewDidDisappear(animated: Bool) {
    super.viewDidDisappear(animated)

}


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

deinit{
    NSNotificationCenter.defaultCenter().removeObserver(self)
    if self.isViewLoaded(){
        self.view.layer .removeAllAnimations();
    }
}

// MARK: - Config
// MARK: - Public methods
// MARK: - Private methods
// MARK: - Target
// MARK: - Action
// MARK: - Notification

}

项目模板

 

-----------------------------------------------------------------------------------------------------------------------------------------------

 

 代码:https://github.com/easyui/XcodeTemplates

 

thx: 

创建Xcode模板:不过倒是发现了一个Xcode插件,专门用来创建模板的:Stencil: A plugin for Xcode allowing you to easily create custom file templates,以及对应的文章:Introducing Stencil,还有一些教程:How to Create Custom Project Templates in Xcode 7Creating Custom Xcode Templates,读者可自行阅读~

 

http://www.bobmccune.com/2012/03/04/creating-custom-xcode-4-file-templates/

http://zengyi.me/blog/2014/08/13/create-custom-xcode5-project-templates/

 

猜你喜欢

转载自justsee.iteye.com/blog/2079621
今日推荐