2017-11-13

Xcode 客製化自己的 File Templae

現在開發環境如果有使用Git and IDE, 因該不用在每一個檔案中加上Creator and Create Time.
在Git 中已經可以回朔開發者, 而且通常不會只有一個人.
在Xcode 中, 每一個新的檔案會加上一堆我不想要的 Comment. 想要每一次開一個新檔案都是可以完全沒有相關的廢物. 
在Xcode 要做到就是利用Templates 來達到, 並且做到個人的客製化.下列步驟就可達到

1. 新增Xcode File Templates , "Custom" 在自己的目錄下. "Custom" 是會出現在你的Xcode新增檔案時的一個大分類, 可以自己取不同的名字, Xcode IDE 會出現不一樣的名字
mkdir -p ~/Library/Developer/Xcode/Templates/File\ Templates/Custom

2.複製原有的Xcode Templates 到你的Templates, 下面是複製Swift 的路徑
cp -R /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/Source/Swift\ File.xctemplate/ ~/Library/Developer/Xcode/Templates/File\ Templates/Custom/Swift\ Class.xctemplate 
 
3. 修改 Template File 內容. 我是直接把 __FILEHEADER__ 拿掉. 達到我不要任何Comment
 
 
參考
1. Creating a reusable file template in xcode
 
 

沒有留言:

張貼留言