
前言
Xcode分为系统模板和自定义模板。模板的好处如下:
1、节省重复代码手写时间
2、统一规范代码,提高代码可读性
3、减少手写代码,XIB或修改相关配置等不必要的时间
iOS系统模板路径如下:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates
自定义模板路径如下:
~/Library/Developer/Xcode/Templates
自定义模板
文件夹
终端打开自定义模板路径
open ~/Library/Developer/Xcode
Xcode目录下依次新建文件夹
Templates-Custom Templates-MVC.xctemplate

TemplateInfo文件
<?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.IDEKit.TextSubstitutionFileTemplateKind</string>
<key>Platforms</key>
<array>
<string>com.apple.platform.iphoneos</string>
</array>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Module Name</string>
<key>Description</key>
<string>template</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>ok Template</string>
<key>Group</key>
<array>
<string>productName</string>
</array>
</dict>
</array>
</dict>
</plist>
MVC模板文件

https://github.com/jackyshan/XcodeiOSTemplate
Xcode新建-选择模板
command+n

输入Module Name

创建文件夹及文件

这种引用目录不是我想要的,删掉-Remove Reference,重新导入文件夹TY_MeiyanSP,选择Create groups

MVC模板导入完成。
网友评论