自定義MVC開發的Xcode模板
阿新 • • 發佈:2020-06-24
前言
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模板匯入完成。