-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.swift
executable file
·39 lines (26 loc) · 1.18 KB
/
install.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Foundation
let templateName = "MVVM File Creator.xctemplate"
let destinationPath = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates"
let oldTemplatePath = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application"
func moveTemplate(){
let fileManager = FileManager.default
do {
if fileManager.fileExists(atPath:"\(oldTemplatePath)/\(templateName)"){
try fileManager.removeItem(atPath: "\(oldTemplatePath)/\(templateName)")
print("Remove old template")
}
} catch let error as NSError {
print("Oops! Something went wrong :( error: \(error.localizedFailureReason!)")
}
do {
if !fileManager.fileExists(atPath:"\(destinationPath)/\(templateName)"){
try fileManager.copyItem(atPath: templateName, toPath: "\(destinationPath)/\(templateName)")
print("File Creator installed succesfully. Enjoy it")
}else{
print("File Creator already exists")
}
} catch let error as NSError {
print("Ooops! Something went wrong: \(error.localizedFailureReason!)")
}
}
moveTemplate()