├── .gitignore ├── .gitmodules ├── CodeSnippets ├── 0C030DB8-4CDC-48C6-8513-7698CEC49CD1.codesnippet ├── 21EDAF82-1352-4828-B1D7-86F13D5AB4C4.codesnippet ├── 2F0D31F6-01D8-4D71-A6D8-8CDE62FA26BC.codesnippet ├── 3432B2E6-95CD-485D-A068-26EF3B147CC5.codesnippet ├── 360B7726-43B0-4F4F-9E92-28C41050957B.codesnippet ├── 3EA2DB1A-03C1-4FE5-96DC-D43DFBB1DE1F.codesnippet ├── 6BBE4649-0541-4518-A58B-C73FFEFF45BB.codesnippet ├── 6F313E53-47CA-4010-A243-0D9A616BC073.codesnippet ├── 70F5EEF4-D403-4184-936D-ED82997145A9.codesnippet ├── 746E395A-2C1F-45FC-90A5-07E4CD822E80.codesnippet ├── 7D6CAC9D-A85A-44D8-9323-5C3F8C6CB566.codesnippet ├── 94DE4856-C663-4E30-854F-621DB762413E.codesnippet ├── 969DC632-4230-4DA9-8544-CD9A424DF016.codesnippet ├── 9AF9D837-9BF8-4619-BA24-E1BAD35E88E5.codesnippet ├── A1B2149F-07C5-4771-8DC3-9778544C8D59.codesnippet ├── A1CB5EB1-C3B4-4569-AA60-B56194EA7167.codesnippet ├── A76ABDA9-D3BF-4C0C-B8C8-B46C090E7FC4.codesnippet ├── AFAA13AE-832D-4ED5-ADE5-ACB22DD340E1.codesnippet ├── BC6C1A89-8095-4CAC-9D69-042A00249063.codesnippet ├── C6C74DDE-E44A-4E7F-9280-F5762707F8C2.codesnippet ├── CAB29747-F6DF-4230-AD99-2BB3E72FA2E9.codesnippet ├── D5D4B813-8050-419F-8918-451A5EB71F21.codesnippet ├── DCC3BB0A-EAA4-4979-9580-7B3D778E1100.codesnippet ├── DCF5F6BB-4585-4AE5-99C0-D9921B93076B.codesnippet ├── F53C91E2-F9BA-4414-8702-81FCCB7B36B8.codesnippet ├── F7F0C095-D562-4C41-850A-1D0FC5310B50.codesnippet └── installer.failurerequests ├── Imgs ├── create_file.gif ├── demo_change.png ├── demo_ff.png ├── demo_ii.png ├── demo_mm.png ├── demo_n.png ├── demo_vv.png ├── diagram.png ├── git_xcode_filetemplate.gif ├── git_xcode_sinppets.gif ├── tu_cs1-1.png ├── tu_cs1-2.png ├── tu_cs1.gif ├── tu_cs2.gif ├── tu_cs3.gif ├── tu_cs4.gif ├── tu_t1.png ├── tu_t2.png ├── tu_t3.png ├── tu_t4.gif ├── tu_t5.png ├── tu_t6.png └── tu_t7.png ├── README.md ├── README_EN.md ├── Templates └── File Templates │ ├── Common │ └── Singlthon Class.xctemplate │ │ ├── TemplateIcon.png │ │ ├── TemplateIcon@2x.png │ │ ├── TemplateInfo.plist │ │ └── ___FILEBASENAME___.swift │ └── UI │ ├── UICollectionView+Xib.xctemplate │ ├── TemplateIcon.png │ ├── TemplateIcon@2x.png │ ├── TemplateInfo.plist │ ├── ___FILEBASENAME___CollectionLayout.swift │ ├── ___FILEBASENAME___CollectionView.swift │ ├── ___FILEBASENAME___CollectionViewCell.swift │ └── ___FILEBASENAME___CollectionViewCell.xib │ ├── UITableView.xctemplate │ ├── TemplateIcon.png │ ├── TemplateIcon@2x.png │ ├── TemplateInfo.plist │ ├── ___FILEBASENAME___TableView.swift │ ├── ___FILEBASENAME___TableViewCell.swift │ └── ___FILEBASENAME___TableViewCell.xib │ ├── UIView+Xib.xctemplate │ ├── TemplateIcon.png │ ├── TemplateIcon@2x.png │ ├── TemplateInfo.plist │ ├── ___FILEBASENAME___View.swift │ └── ___FILEBASENAME___View.xib │ └── UIView.xctemplate │ ├── TemplateIcon.png │ ├── TemplateIcon@2x.png │ ├── TemplateInfo.plist │ └── ___FILEBASENAME___.swift ├── Tutorials ├── README_CS.md ├── README_CS_CN.md ├── README_T.md └── README_T_CN.md └── xcode-sync.sh /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | 3 | Templates/File\ Templates/Clean\ Swift 4 | Templates/File\ Templates/MVVMLibrary 5 | Templates/File\ Templates/MVVM 6 | Templates/File\ Templates/Temp 7 | 8 | source 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "fsevents-tools"] 2 | path = fsevents-tools 3 | url = https://github.com/5SMNOONMS5/fsevents-tools.git 4 | -------------------------------------------------------------------------------- /CodeSnippets/0C030DB8-4CDC-48C6-8513-7698CEC49CD1.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - CALayer 7 | IDECodeSnippetCompletionScopes 8 | 9 | CodeBlock 10 | 11 | IDECodeSnippetContents 12 | let <#name#> = CALayer() 13 | <#name#>.frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 14 | <#name#>.backgroundColor = <#UIColor#> 15 | view.layer.addSublayer(<#name#>) 16 | IDECodeSnippetIdentifier 17 | 0C030DB8-4CDC-48C6-8513-7698CEC49CD1 18 | IDECodeSnippetLanguage 19 | Xcode.SourceCodeLanguage.Swift 20 | IDECodeSnippetPlatformFamily 21 | iphoneos 22 | IDECodeSnippetTitle 23 | Init A CALayer 24 | IDECodeSnippetUserSnippet 25 | 26 | IDECodeSnippetVersion 27 | 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /CodeSnippets/21EDAF82-1352-4828-B1D7-86F13D5AB4C4.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - Tap Gesture 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <# Variable #> = UITapGestureRecognizer(target: <#T##Any?#>, action: #selector(<# Target #>.actionTap)) 13 | self.<# Target #>.addGestureRecognizer(<# Variable #>) 14 | 15 | @objc func actionTap() -> Void { 16 | 17 | } 18 | IDECodeSnippetIdentifier 19 | 21EDAF82-1352-4828-B1D7-86F13D5AB4C4 20 | IDECodeSnippetLanguage 21 | Xcode.SourceCodeLanguage.Swift 22 | IDECodeSnippetPlatformFamily 23 | iphoneos 24 | IDECodeSnippetTitle 25 | Init A UITapGesture 26 | IDECodeSnippetUserSnippet 27 | 28 | IDECodeSnippetVersion 29 | 2 30 | 31 | 32 | -------------------------------------------------------------------------------- /CodeSnippets/2F0D31F6-01D8-4D71-A6D8-8CDE62FA26BC.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UISwitch 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <#switch#> = UISwitch(frame: CGRect(x: <# x #>, y: <# y #>, width: <# width #>, height: <# height #>)) 13 | <#switch#>.thumbTintColor = <#.color#> 14 | <#switch#>.onTintColor = <#.color#> 15 | <#switch#>.tintColor = <#.color#> 16 | <#switch#>.addTarget(self, action: #selector(<#ViewController#>.switchAction(sender:)), for: .valueChanged) 17 | view.addSubview(<#switch#>) 18 | 19 | func switchAction(sender: UISwitch){ 20 | // sender.isOn 21 | } 22 | IDECodeSnippetIdentifier 23 | 2F0D31F6-01D8-4D71-A6D8-8CDE62FA26BC 24 | IDECodeSnippetLanguage 25 | Xcode.SourceCodeLanguage.Swift 26 | IDECodeSnippetPlatformFamily 27 | iphoneos 28 | IDECodeSnippetTitle 29 | Init A UISwitch 30 | IDECodeSnippetUserSnippet 31 | 32 | IDECodeSnippetVersion 33 | 2 34 | 35 | 36 | -------------------------------------------------------------------------------- /CodeSnippets/3432B2E6-95CD-485D-A068-26EF3B147CC5.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UISegmentedControl 7 | IDECodeSnippetCompletionScopes 8 | 9 | CodeBlock 10 | 11 | IDECodeSnippetContents 12 | let <#segment#> = UISegmentedControl(items: <#T##[Any]?#>) 13 | <#segment#>.frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 14 | <#segment#>.addTarget(self, action: #selector(<#ViewController#>.segmentTouch(sender:)), for: .valueChanged) 15 | view.addSubview(<#segment#>) 16 | 17 | 18 | func segmentTouch(sender: UISegmentedControl){ 19 | // sender.titleForSegment(at: sender.selectedSegmentIndex) 20 | } 21 | IDECodeSnippetIdentifier 22 | 3432B2E6-95CD-485D-A068-26EF3B147CC5 23 | IDECodeSnippetLanguage 24 | Xcode.SourceCodeLanguage.Swift 25 | IDECodeSnippetPlatformFamily 26 | iphoneos 27 | IDECodeSnippetTitle 28 | Init A UISegmentedControl 29 | IDECodeSnippetUserSnippet 30 | 31 | IDECodeSnippetVersion 32 | 2 33 | 34 | 35 | -------------------------------------------------------------------------------- /CodeSnippets/360B7726-43B0-4F4F-9E92-28C41050957B.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | SS 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | #selector(<# ClassName #>.<# MethodName #>(_:)) 13 | IDECodeSnippetIdentifier 14 | 360B7726-43B0-4F4F-9E92-28C41050957B 15 | IDECodeSnippetLanguage 16 | Xcode.SourceCodeLanguage.Swift 17 | IDECodeSnippetTitle 18 | Selector 19 | IDECodeSnippetUserSnippet 20 | 21 | IDECodeSnippetVersion 22 | 2 23 | 24 | 25 | -------------------------------------------------------------------------------- /CodeSnippets/3EA2DB1A-03C1-4FE5-96DC-D43DFBB1DE1F.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UIButton 7 | IDECodeSnippetCompletionScopes 8 | 9 | CodeBlock 10 | 11 | IDECodeSnippetContents 12 | let <#btn#> = UIButton(type: .system) 13 | <#btn#>.frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 14 | <#btn#>.setTitle(<#title#>, for: .normal) 15 | <#btn#>.addTarget(self, action: #selector(<#ViewController#>.buttonTouch(sender:)), for: .touchUpInside) 16 | view.addSubview(<#btn#>) 17 | 18 | func buttonTouch(sender: UIButton){ 19 | print("The button was touched") 20 | } 21 | 22 | IDECodeSnippetIdentifier 23 | 3EA2DB1A-03C1-4FE5-96DC-D43DFBB1DE1F 24 | IDECodeSnippetLanguage 25 | Xcode.SourceCodeLanguage.Swift 26 | IDECodeSnippetPlatformFamily 27 | iphoneos 28 | IDECodeSnippetTitle 29 | Init A UIButton 30 | IDECodeSnippetUserSnippet 31 | 32 | IDECodeSnippetVersion 33 | 2 34 | 35 | 36 | -------------------------------------------------------------------------------- /CodeSnippets/6BBE4649-0541-4518-A58B-C73FFEFF45BB.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UIView 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <#name#> = UIView() 13 | <#name#>.frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 14 | <#name#>.backgroundColor = <#UIColor#> 15 | view.addSubview(<#name#>) 16 | IDECodeSnippetIdentifier 17 | 6BBE4649-0541-4518-A58B-C73FFEFF45BB 18 | IDECodeSnippetLanguage 19 | Xcode.SourceCodeLanguage.Swift 20 | IDECodeSnippetPlatformFamily 21 | iphoneos 22 | IDECodeSnippetTitle 23 | Init A UIView 24 | IDECodeSnippetUserSnippet 25 | 26 | IDECodeSnippetVersion 27 | 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /CodeSnippets/6F313E53-47CA-4010-A243-0D9A616BC073.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - AlertViewController 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <#name#> = UIAlertController(title: <#T##String?#>, 13 | message: <#T##String?#>, 14 | preferredStyle: <#T##UIAlertControllerStyle#>) 15 | 16 | let <#action1#> = UIAlertAction(title: <#T##String?#>, 17 | style: <#T##UIAlertActionStyle#>){ (<#UIAlertAction#>) in 18 | <#code#> 19 | } 20 | let <#action2#> = UIAlertAction(title: <#T##String?#>, 21 | style: <#T##UIAlertActionStyle#>){ (<#UIAlertAction#>) in 22 | <#code#> 23 | } 24 | 25 | <#name#>.addAction(<#action1#>) 26 | <#name#>.addAction(<#action2#>) 27 | self.present(<#T##UIViewController#>, animated: <#T##Bool#>, completion: <#T##(() -> Void)?##(() -> Void)?##() -> Void#>) 28 | IDECodeSnippetIdentifier 29 | 6F313E53-47CA-4010-A243-0D9A616BC073 30 | IDECodeSnippetLanguage 31 | Xcode.SourceCodeLanguage.Swift 32 | IDECodeSnippetPlatformFamily 33 | iphoneos 34 | IDECodeSnippetTitle 35 | Init A AlertViewController With Actions 36 | IDECodeSnippetUserSnippet 37 | 38 | IDECodeSnippetVersion 39 | 2 40 | 41 | 42 | -------------------------------------------------------------------------------- /CodeSnippets/70F5EEF4-D403-4184-936D-ED82997145A9.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | VV - View Lift Cycle 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | // ****************************************** 13 | // 14 | // MARK: - View Life Cycle 15 | // 16 | // ****************************************** 17 | 18 | override func viewWillAppear(animated: Bool) { 19 | super.viewWillAppear(true) 20 | } 21 | 22 | override func viewDidAppear(animated: Bool) { 23 | super.viewDidAppear(true) 24 | } 25 | 26 | override func viewWillDisappear(animated: Bool) { 27 | super.viewWillDisappear(true) 28 | } 29 | 30 | override func viewDidDisappear(animated: Bool) { 31 | super.viewDidDisappear(true) 32 | } 33 | IDECodeSnippetIdentifier 34 | 70F5EEF4-D403-4184-936D-ED82997145A9 35 | IDECodeSnippetLanguage 36 | Xcode.SourceCodeLanguage.Swift 37 | IDECodeSnippetPlatformFamily 38 | iphoneos 39 | IDECodeSnippetTitle 40 | View Lift Cycle 41 | IDECodeSnippetUserSnippet 42 | 43 | IDECodeSnippetVersion 44 | 2 45 | 46 | 47 | -------------------------------------------------------------------------------- /CodeSnippets/746E395A-2C1F-45FC-90A5-07E4CD822E80.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - WKWebView 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | import WebKit 13 | 14 | func setupWKWebView(){ 15 | 16 | let frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 17 | let <#name#> = WKWebView(frame: frame, configuration: <#T##WKWebViewConfiguration#>) 18 | <#name#>.uiDelegate = self 19 | view.addSubview(<#name#>) 20 | 21 | let <#url#> = URL(string: <#string#>) 22 | 23 | guard let <#newURL#> = <#url#> else { 24 | print(<#not get url#>) 25 | } 26 | let <#request#> = URLRequest(url: <#newURL#>) 27 | <#name#>.load(<#request#>) 28 | 29 | } 30 | 31 | 32 | extension <#UIViewController#> : WKUIDelegate{ 33 | 34 | 35 | } 36 | IDECodeSnippetIdentifier 37 | 746E395A-2C1F-45FC-90A5-07E4CD822E80 38 | IDECodeSnippetLanguage 39 | Xcode.SourceCodeLanguage.Swift 40 | IDECodeSnippetPlatformFamily 41 | iphoneos 42 | IDECodeSnippetTitle 43 | Init A WKWebView 44 | IDECodeSnippetUserSnippet 45 | 46 | IDECodeSnippetVersion 47 | 2 48 | 49 | 50 | -------------------------------------------------------------------------------- /CodeSnippets/7D6CAC9D-A85A-44D8-9323-5C3F8C6CB566.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - Playground 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | import UIKit 13 | import PlaygroundSupport 14 | 15 | let view = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 500)) 16 | view.backgroundColor = UIColor.blue 17 | 18 | PlaygroundPage.current.liveView = view 19 | PlaygroundPage.current.needsIndefiniteExecution = true 20 | IDECodeSnippetIdentifier 21 | 7D6CAC9D-A85A-44D8-9323-5C3F8C6CB566 22 | IDECodeSnippetLanguage 23 | Xcode.SourceCodeLanguage.Swift 24 | IDECodeSnippetPlatformFamily 25 | iphoneos 26 | IDECodeSnippetTitle 27 | Init A Playground Live Render 28 | IDECodeSnippetUserSnippet 29 | 30 | IDECodeSnippetVersion 31 | 2 32 | 33 | 34 | -------------------------------------------------------------------------------- /CodeSnippets/94DE4856-C663-4E30-854F-621DB762413E.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UIImageView 7 | IDECodeSnippetCompletionScopes 8 | 9 | CodeBlock 10 | 11 | IDECodeSnippetContents 12 | let <# name #> = UIImageView(image: UIImage(named: <#image name#>)) 13 | <# name #>.frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 14 | <# name #>.contentMode = <#UIViewContentMode#> 15 | <# name #>.backgroundColor = <#UIColor#> 16 | view.addSubview(<# name #>) 17 | 18 | IDECodeSnippetIdentifier 19 | 94DE4856-C663-4E30-854F-621DB762413E 20 | IDECodeSnippetLanguage 21 | Xcode.SourceCodeLanguage.Swift 22 | IDECodeSnippetPlatformFamily 23 | iphoneos 24 | IDECodeSnippetTitle 25 | Init A UIImageView 26 | IDECodeSnippetUserSnippet 27 | 28 | IDECodeSnippetVersion 29 | 2 30 | 31 | 32 | -------------------------------------------------------------------------------- /CodeSnippets/969DC632-4230-4DA9-8544-CD9A424DF016.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UILabel 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <#name#> = UILabel() 13 | <#name#>.frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 14 | <#name#>.font = <#UIFont#> 15 | <#name#>.textColor = <#UIColor#> 16 | <#name#>.text = <#String#> 17 | <#name#>.textAlignment = <#NSTextAlignment#> 18 | view.addSubview(<#name#>) 19 | IDECodeSnippetIdentifier 20 | 969DC632-4230-4DA9-8544-CD9A424DF016 21 | IDECodeSnippetLanguage 22 | Xcode.SourceCodeLanguage.Swift 23 | IDECodeSnippetPlatformFamily 24 | iphoneos 25 | IDECodeSnippetTitle 26 | Init A UILabel 27 | IDECodeSnippetUserSnippet 28 | 29 | IDECodeSnippetVersion 30 | 2 31 | 32 | 33 | -------------------------------------------------------------------------------- /CodeSnippets/9AF9D837-9BF8-4619-BA24-E1BAD35E88E5.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - Function 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | 13 | <# Access Controll #> func <# FuncName #>() -> Void { 14 | 15 | } 16 | IDECodeSnippetIdentifier 17 | 9AF9D837-9BF8-4619-BA24-E1BAD35E88E5 18 | IDECodeSnippetLanguage 19 | Xcode.SourceCodeLanguage.Swift 20 | IDECodeSnippetPlatformFamily 21 | iphoneos 22 | IDECodeSnippetTitle 23 | Init A Function 24 | IDECodeSnippetUserSnippet 25 | 26 | IDECodeSnippetVersion 27 | 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /CodeSnippets/A1B2149F-07C5-4771-8DC3-9778544C8D59.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UISlider 7 | IDECodeSnippetCompletionScopes 8 | 9 | CodeBlock 10 | 11 | IDECodeSnippetContents 12 | let <#slider#> = UISlider(frame: CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>)) 13 | <#slider#>.maximumValue = <#Float#> 14 | <#slider#>.minimumValue = <#Float#> 15 | <#slider#>.value = <#Float#> 16 | <#slider#>.maximumTrackTintColor = <#.color#> 17 | <#slider#>.minimumTrackTintColor = <#.color#> 18 | <#slider#>.thumbTintColor = <#.color#> 19 | <#slider#>.addTarget(self, action: #selector(<#ViewController#>.sliderAction(sender:)), for: .valueChanged) 20 | view.addSubview(<#slider#>) 21 | 22 | func sliderAction(sender: UISlider){ 23 | // sender.value 24 | } 25 | IDECodeSnippetIdentifier 26 | A1B2149F-07C5-4771-8DC3-9778544C8D59 27 | IDECodeSnippetLanguage 28 | Xcode.SourceCodeLanguage.Swift 29 | IDECodeSnippetPlatformFamily 30 | iphoneos 31 | IDECodeSnippetTitle 32 | Init A UISlider 33 | IDECodeSnippetUserSnippet 34 | 35 | IDECodeSnippetVersion 36 | 2 37 | 38 | 39 | -------------------------------------------------------------------------------- /CodeSnippets/A1CB5EB1-C3B4-4569-AA60-B56194EA7167.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UITextView 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <#textView#> = UITextView(frame: CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>)) 13 | <#textView#>.text = <#content#> 14 | view.addSubview(<#textView#>) 15 | IDECodeSnippetIdentifier 16 | A1CB5EB1-C3B4-4569-AA60-B56194EA7167 17 | IDECodeSnippetLanguage 18 | Xcode.SourceCodeLanguage.Swift 19 | IDECodeSnippetPlatformFamily 20 | iphoneos 21 | IDECodeSnippetTitle 22 | Init A UITextView 23 | IDECodeSnippetUserSnippet 24 | 25 | IDECodeSnippetVersion 26 | 2 27 | 28 | 29 | -------------------------------------------------------------------------------- /CodeSnippets/A76ABDA9-D3BF-4C0C-B8C8-B46C090E7FC4.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <#name#> = UIAlertController(title: <#String#>, message: <#String#>, preferredStyle: <#UIAlertControllerStyle#>) 13 | 14 | let <#action#> = UIAlertAction(title: <#String#>, style: <#UIAlertActionStyle#>) { action -> Void in 15 | //code here 16 | } 17 | <#name#>.addAction(<#action#>) 18 | 19 | let <#action2#> = UIAlertAction(title: <#String#>, style: <#UIAlertActionStyle#>) { action -> Void in 20 | //code here 21 | } 22 | <#name#>.addAction(<#action2#>) 23 | 24 | //Present the AlertController 25 | self.present(<#name#>, animated: true, completion: nil) 26 | IDECodeSnippetIdentifier 27 | A76ABDA9-D3BF-4C0C-B8C8-B46C090E7FC4 28 | IDECodeSnippetLanguage 29 | Xcode.SourceCodeLanguage.Swift 30 | IDECodeSnippetTitle 31 | Init a UIAlertController 32 | IDECodeSnippetUserSnippet 33 | 34 | IDECodeSnippetVersion 35 | 2 36 | 37 | 38 | -------------------------------------------------------------------------------- /CodeSnippets/AFAA13AE-832D-4ED5-ADE5-ACB22DD340E1.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UIProgressView 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <#name#> = UIProgressView() 13 | <#name#>.frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 14 | <#name#>.progress = <#Float#> 15 | <#name#>.trackTintColor = <# UIColor#> 16 | <#name#>.progressTintColor = <# UIColor#> 17 | <#name#>.progressViewStyle = <# UIProgressViewStyle#> 18 | view.addSubview(<#name#>) 19 | IDECodeSnippetIdentifier 20 | AFAA13AE-832D-4ED5-ADE5-ACB22DD340E1 21 | IDECodeSnippetLanguage 22 | Xcode.SourceCodeLanguage.Swift 23 | IDECodeSnippetPlatformFamily 24 | iphoneos 25 | IDECodeSnippetTitle 26 | Init A UIProgressView 27 | IDECodeSnippetUserSnippet 28 | 29 | IDECodeSnippetVersion 30 | 2 31 | 32 | 33 | -------------------------------------------------------------------------------- /CodeSnippets/BC6C1A89-8095-4CAC-9D69-042A00249063.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - Method swizzle 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | extension NSObject { 13 | class func brc_swizzleMethod(_ origSelector: Selector, withMethod newSelector: Selector) { 14 | let origMethod = class_getInstanceMethod(self, origSelector) 15 | let newMethod = class_getInstanceMethod(self, newSelector) 16 | if class_addMethod(self, origSelector, method_getImplementation(newMethod!), method_getTypeEncoding(newMethod!)) { 17 | class_replaceMethod(self, newSelector, method_getImplementation(origMethod!), method_getTypeEncoding(origMethod!)) 18 | } 19 | else { 20 | method_exchangeImplementations(origMethod!, newMethod!) 21 | } 22 | } 23 | } 24 | IDECodeSnippetIdentifier 25 | BC6C1A89-8095-4CAC-9D69-042A00249063 26 | IDECodeSnippetLanguage 27 | Xcode.SourceCodeLanguage.Swift 28 | IDECodeSnippetPlatformFamily 29 | iphoneos 30 | IDECodeSnippetTitle 31 | Method Swizzle 32 | IDECodeSnippetUserSnippet 33 | 34 | IDECodeSnippetVersion 35 | 2 36 | 37 | 38 | -------------------------------------------------------------------------------- /CodeSnippets/C6C74DDE-E44A-4E7F-9280-F5762707F8C2.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UIBarButtonItem 7 | IDECodeSnippetCompletionScopes 8 | 9 | CodeBlock 10 | 11 | IDECodeSnippetContents 12 | let <#barButtonItem#> = UIBarButtonItem(title: "Back", style: .plain, target: self, action: #selector(<#ViewController#>.barButtonItemAction)) 13 | self.navigationItem.leftBarButtonItem = <#barButtonItem#> 14 | 15 | func barButtonItemAction(){ 16 | 17 | } 18 | IDECodeSnippetIdentifier 19 | C6C74DDE-E44A-4E7F-9280-F5762707F8C2 20 | IDECodeSnippetLanguage 21 | Xcode.SourceCodeLanguage.Swift 22 | IDECodeSnippetPlatformFamily 23 | iphoneos 24 | IDECodeSnippetTitle 25 | Init A UIBarButtonItem 26 | IDECodeSnippetUserSnippet 27 | 28 | IDECodeSnippetVersion 29 | 2 30 | 31 | 32 | -------------------------------------------------------------------------------- /CodeSnippets/CAB29747-F6DF-4230-AD99-2BB3E72FA2E9.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | FF - FixMe 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | /// FIXME: o 13 | 14 | IDECodeSnippetIdentifier 15 | CAB29747-F6DF-4230-AD99-2BB3E72FA2E9 16 | IDECodeSnippetLanguage 17 | Xcode.SourceCodeLanguage.Swift 18 | IDECodeSnippetPlatformFamily 19 | iphoneos 20 | IDECodeSnippetTitle 21 | Custom flag 22 | IDECodeSnippetUserSnippet 23 | 24 | IDECodeSnippetVersion 25 | 2 26 | 27 | 28 | -------------------------------------------------------------------------------- /CodeSnippets/D5D4B813-8050-419F-8918-451A5EB71F21.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - SnapKit 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | <# View #> = <# View #>(frame: .zero) 13 | <# View #>.addSubview(<# View #>) 14 | <# View #>.snp.makeConstraints { (make) in 15 | <#code#> 16 | } 17 | IDECodeSnippetIdentifier 18 | D5D4B813-8050-419F-8918-451A5EB71F21 19 | IDECodeSnippetLanguage 20 | Xcode.SourceCodeLanguage.Swift 21 | IDECodeSnippetPlatformFamily 22 | iphoneos 23 | IDECodeSnippetTitle 24 | Init A View With Snapkit 25 | IDECodeSnippetUserSnippet 26 | 27 | IDECodeSnippetVersion 28 | 2 29 | 30 | 31 | -------------------------------------------------------------------------------- /CodeSnippets/DCC3BB0A-EAA4-4979-9580-7B3D778E1100.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UIScrollView 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | let <#name#> = UIScrollView() 13 | <#name#>.frame = CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>) 14 | <#name#>.contentSize = CGSize(width: <#T##Double#>, height: <#T##Double#>) 15 | <#name#>.contentInset = UIEdgeInsetsMake(<#T##top: CGFloat##CGFloat#>, <#T##left: CGFloat##CGFloat#>, <#T##bottom: CGFloat##CGFloat#>, <#T##right: CGFloat##CGFloat#>) 16 | <#name#>.contentOffset = CGPoint(x: <#T##Double#>, y: <#T##Double#>) 17 | view.addSubview(<#name#>) 18 | IDECodeSnippetIdentifier 19 | DCC3BB0A-EAA4-4979-9580-7B3D778E1100 20 | IDECodeSnippetLanguage 21 | Xcode.SourceCodeLanguage.Swift 22 | IDECodeSnippetPlatformFamily 23 | iphoneos 24 | IDECodeSnippetTitle 25 | Init A UIScrollView 26 | IDECodeSnippetUserSnippet 27 | 28 | IDECodeSnippetVersion 29 | 2 30 | 31 | 32 | -------------------------------------------------------------------------------- /CodeSnippets/DCF5F6BB-4585-4AE5-99C0-D9921B93076B.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - UITextField 7 | IDECodeSnippetCompletionScopes 8 | 9 | CodeBlock 10 | 11 | IDECodeSnippetContents 12 | let <#textField#> = UITextField(frame: CGRect(x: <#T##Double#>, y: <#T##Double#>, width: <#T##Double#>, height: <#T##Double#>)) 13 | <#textField#>.placeholder = <#Content#> 14 | <#textField#>.borderStyle = <#.Style#> 15 | <#textField#>.delegate = self 16 | view.addSubview(<#textField#>) 17 | 18 | extension <#ViewController#>: UITextFieldDelegate{ 19 | func textFieldDidBeginEditing(_ textField: UITextField) { 20 | <#code#> 21 | } 22 | 23 | func textFieldDidEndEditing(_ textField: UITextField) { 24 | <#code#> 25 | } 26 | } 27 | IDECodeSnippetIdentifier 28 | DCF5F6BB-4585-4AE5-99C0-D9921B93076B 29 | IDECodeSnippetLanguage 30 | Xcode.SourceCodeLanguage.Swift 31 | IDECodeSnippetPlatformFamily 32 | iphoneos 33 | IDECodeSnippetTitle 34 | Init A UITextField 35 | IDECodeSnippetUserSnippet 36 | 37 | IDECodeSnippetVersion 38 | 2 39 | 40 | 41 | -------------------------------------------------------------------------------- /CodeSnippets/F53C91E2-F9BA-4414-8702-81FCCB7B36B8.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | II - CAGradientLayer 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | /// Gradient layer 13 | let gradient: CAGradientLayer = CAGradientLayer() 14 | 15 | let colors = [UIColor(red:0.18, green:0.38, blue:0.76, alpha:1.0).cgColor, 16 | UIColor(red:0.02, green:0.05, blue:0.15, alpha:1.0).cgColor] 17 | gradient.colors = colors 18 | 19 | gradient.locations = [0.0, 1.0] 20 | gradient.startPoint = CGPoint(x: <# x #>, y: <# y #>) 21 | gradient.endPoint = CGPoint(x: <# x #>, y: <# y #>) 22 | gradient.frame = CGRect(x: <# x #> , y: <# y #>, width: <# width #>, height: <# height #>) 23 | gradient.opacity = <# opacity #> 24 | IDECodeSnippetIdentifier 25 | F53C91E2-F9BA-4414-8702-81FCCB7B36B8 26 | IDECodeSnippetLanguage 27 | Xcode.SourceCodeLanguage.Swift 28 | IDECodeSnippetPlatformFamily 29 | iphoneos 30 | IDECodeSnippetTitle 31 | Init A CAGradientLayer 32 | IDECodeSnippetUserSnippet 33 | 34 | IDECodeSnippetVersion 35 | 2 36 | 37 | 38 | -------------------------------------------------------------------------------- /CodeSnippets/F7F0C095-D562-4C41-850A-1D0FC5310B50.codesnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDECodeSnippetCompletionPrefix 6 | MM 7 | IDECodeSnippetCompletionScopes 8 | 9 | All 10 | 11 | IDECodeSnippetContents 12 | // ****************************************** 13 | // 14 | // MARK: - 15 | // 16 | // ****************************************** 17 | IDECodeSnippetIdentifier 18 | F7F0C095-D562-4C41-850A-1D0FC5310B50 19 | IDECodeSnippetLanguage 20 | Xcode.SourceCodeLanguage.Swift 21 | IDECodeSnippetTitle 22 | MARK Comments 23 | IDECodeSnippetUserSnippet 24 | 25 | IDECodeSnippetVersion 26 | 2 27 | 28 | 29 | -------------------------------------------------------------------------------- /CodeSnippets/installer.failurerequests: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Operation 7 | fsck target 8 | CrashAtProgress 9 | 0 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Imgs/create_file.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/create_file.gif -------------------------------------------------------------------------------- /Imgs/demo_change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/demo_change.png -------------------------------------------------------------------------------- /Imgs/demo_ff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/demo_ff.png -------------------------------------------------------------------------------- /Imgs/demo_ii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/demo_ii.png -------------------------------------------------------------------------------- /Imgs/demo_mm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/demo_mm.png -------------------------------------------------------------------------------- /Imgs/demo_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/demo_n.png -------------------------------------------------------------------------------- /Imgs/demo_vv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/demo_vv.png -------------------------------------------------------------------------------- /Imgs/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/diagram.png -------------------------------------------------------------------------------- /Imgs/git_xcode_filetemplate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/git_xcode_filetemplate.gif -------------------------------------------------------------------------------- /Imgs/git_xcode_sinppets.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/git_xcode_sinppets.gif -------------------------------------------------------------------------------- /Imgs/tu_cs1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_cs1-1.png -------------------------------------------------------------------------------- /Imgs/tu_cs1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_cs1-2.png -------------------------------------------------------------------------------- /Imgs/tu_cs1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_cs1.gif -------------------------------------------------------------------------------- /Imgs/tu_cs2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_cs2.gif -------------------------------------------------------------------------------- /Imgs/tu_cs3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_cs3.gif -------------------------------------------------------------------------------- /Imgs/tu_cs4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_cs4.gif -------------------------------------------------------------------------------- /Imgs/tu_t1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_t1.png -------------------------------------------------------------------------------- /Imgs/tu_t2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_t2.png -------------------------------------------------------------------------------- /Imgs/tu_t3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_t3.png -------------------------------------------------------------------------------- /Imgs/tu_t4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_t4.gif -------------------------------------------------------------------------------- /Imgs/tu_t5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_t5.png -------------------------------------------------------------------------------- /Imgs/tu_t6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_t6.png -------------------------------------------------------------------------------- /Imgs/tu_t7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Imgs/tu_t7.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XcodeSyncTools 2 | 3 | [A English version of this document can be found here](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/README_EN.md) 4 | 5 | 同步 Xcode 在不同電腦裡內建的 **Code-Snippets (程式碼片段)** 還有 **File-Template (檔案模板)**。 6 | 7 | ## 什麼是 Code-Snippets 跟 File-Template? 8 | 9 | * [如何製作 Code-Snippets (圖文教學)](Tutorials/README_CS_CN.md) 10 | 11 | ### Code-Snippets 12 | 13 | ![](Imgs/git_xcode_sinppets.gif) 14 | 15 | * 根據自定義關鍵字,返回一段預先寫好的 Snippet。 16 | 17 | ### File-Template 18 | 19 | * [如何製作 File-Template (圖文教學)](Tutorials/README_T_CN.md) 20 | 21 | ![](Imgs/git_xcode_filetemplate.gif) 22 | 23 | * 跟 Code-Snippets 的概念是一樣的,但可以依照預先創建好 資料夾結構。 24 | 25 | ## 專案流程 26 | 27 | ![](Imgs/diagram.png) 28 | 29 | * Git clone 之後到本機的 XcodeSyncTools 目錄底下,然後執行腳本會將 XcodeSyncTools 目錄底下的檔案 copy 一份到 /Users//Library/Developer/Xcode 底下 (以下簡稱 Xcode 目錄底下),那 **假如** 有在終端機上面執行 [fsevents-tools](https://github.com/ggreer/fsevents-tools) 的話,就會開始**監聽** 30 | Xcode 目錄底下的檔案變化,然後同步回去 XcodeSyncTools 目錄底下。 31 | 32 | * 其實最主要還是透過 git 去管理,但在這邊想分享的是 [fsevents-tools](https://github.com/ggreer/fsevents-tools) 。 fsevents-tools 利用 OS X's [FSEvents](https://en.wikipedia.org/wiki/FSEvents) API 來監聽檔案或者目錄的變化, 33 | 只要發生任何變化 (新增,刪除,修改) 就會 **接 (pipe)** 著執行 [rsync](https://zh.wikipedia.org/wiki/Rsync) ,將 Xcode 目錄底下的 File-Template 還有 Code-Snippets 同步到 XcodeSyncTools 底下的資料夾,這樣每當開發者在 Xcode 裡面修正樣板程式碼的時候,XcodeSyncTools 專案底下的檔案也會隨著一起變動。然後再透過 git 來達到同步的效果,你可以把 fsevents-tools 想成是 OS X 版本的 [inotify](https://zh.wikipedia.org/wiki/Inotify)。 34 | 35 | ## 如果不用這專案會怎樣嗎? 36 | 37 | * 完全不會怎樣,因為大部分的開發者在修正 File-Template 或者 Code-Snippets 時都會在 Xcode 中去製作 (詳情可以看教學部分 [Code-Snippets](Tutorials/README_CS_CN.md) , [File-Template](Tutorials/README_T_CN.md)),那當製作完了通常會需要在**手動**去同步,那如果使用 [fsevents-tools](https://github.com/ggreer/fsevents-tools) 的話則可以省去這個步驟。 38 | 39 | > 您也可以將 pipe 之後接成任意腳本去執行。(ex: 執行 githook 或者 git push) 40 | 41 | ## 如何開始 42 | 43 | * 把專案 clone 下來。 44 | * 執行腳本,會將 CodeSnippets 跟 Templates 資料夾底下的檔案複製一份到 Xcode 的 CodeSnippets 跟 Templates 底下。(如果已經有舊的,那會把舊的複製一份保存下來) 45 | 46 | * 註:不要直接載下來,因為我是用 [git Submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodule) 的方式把 [fsevents-tools](https://github.com/ggreer/fsevents-tools) 加進這專案裡面。 47 | 48 | ```bash 49 | # 第 1 步: clone 50 | # 透過 Http 51 | git clone --depth 1 https://github.com/5SMNOONMS5/XcodeSyncTools.git 52 | 53 | # 第 2 步: 移動工作目錄到 XcodeSyncTools 底下 54 | cd XcodeSyncTools 55 | 56 | # 第 3 步: 同步所有檔案,**只有第一次需要使用**,之後請用 -w 來監聽即可 57 | sh xcode-sync.sh -s 58 | 59 | # 第 4 步: 打開 Xcode , 開始享用:) 60 | ``` 61 | 62 | ## 更多 63 | 64 | ```bash 65 | sh xcode-sync.sh -h 66 | ``` 67 | 68 | ## 監聽 69 | 70 | ```bash 71 | sh xcode-sync.sh -w 72 | ``` 73 | 74 | ## 擁有自己的 Code-Snippets 及 File-Template 75 | 76 | 這專案的 Code-Snippets 跟 File-Template 都大多數都偏向個人使用, 但如果想使用自己的 repo 可以修正在 xcode-sync.sh 裡面的 path_source_url 變數 77 | 78 | ![](Imgs/demo_change.png) 79 | 80 | 修正後,記得 run 81 | 82 | ```bash 83 | sh xcode-sync.sh -c 84 | ``` 85 | 86 | 接著就一連串的 add commit push 迴圈,開啟專屬您的 Code-Snippets 以及 File-Template。 87 | 88 | ## Code-Snippets 使用關鍵字 89 | 90 | ### II 91 | 92 | Type **II** ( 大部分物件的初始化 ) 93 | 94 | ![](Imgs/demo_ii.png) 95 | 96 | ### FF 97 | 98 | Type **FF** ( 客製的 swift flag ) 99 | 100 | ![](Imgs/demo_ff.png) 101 | 102 | ### MM 103 | 104 | Type **MM** ( Mark ) 105 | 106 | ![](Imgs/demo_mm.png) 107 | 108 | ### VV 109 | 110 | 按下 **VV** ( View 的生命週期 ) 111 | 112 | ![](Imgs/demo_vv.png) 113 | 114 | ## File-Template 使用方式 115 | 116 | 打開 Xcode,並且像往常那樣新增檔案 File -> New -> File,滑到最下面就會發現惹 117 | 118 | ![](Imgs/demo_n.png) 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /README_EN.md: -------------------------------------------------------------------------------- 1 | 2 | # XcodeSyncTools (Not done yet) 3 | 4 | [中文版 README](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/README.md) 5 | 6 | My personal xcode **code-snippets** and **file-template** sync tool. 7 | 8 | ## What is code-snippet and file-template in Xcode?? 9 | 10 | ### code-snippet 11 | 12 | ![](Imgs/git_xcode_sinppets.gif) 13 | 14 | Place your customize keyword and your buildin snippets will popup for you, it save times for you. 15 | 16 | ### file-templates 17 | 18 | ![](Imgs/git_xcode_filetemplate.gif) 19 | 20 | Like code-snippet, but additional it creates folders, files and xibs for you. 21 | 22 | ## What is this project do?? 23 | 24 | Sync multiply code-snippet and file-template within different computers. 25 | 26 | ## Core concept 27 | 28 | ![](Imgs/diagram.png) 29 | 30 | It very easy to understand via the above diagram, but here I want to share about [fsevents-tools](https://github.com/ggreer/fsevents-tools), [fsevents-tools](https://github.com/ggreer/fsevents-tools) uses [FSEvents](https://developer.apple.com/library/content/documentation/Darwin/Conceptual/FSEvents_ProgGuide/Introduction/Introduction.html)[wiki](https://en.wikipedia.org/wiki/FSEvents) that allows you to observer the changes in given directory then hook your own script. For my case, I use fsevents-tools to listen to the folders **CodeSnippets** and **Templates**, while developer delete, create or modify any files, it then run [rsync](https://zh.wikipedia.org/wiki/Rsync) to sync between the folders under this project and xcode. 31 | 32 | ## Quick Start 33 | 34 | ```bash 35 | # Step 1: Clone first 36 | 37 | # SSH 38 | git clone git@github.com:5SMNOONMS5/XcodeSyncTools.git 39 | 40 | # Http 41 | git clone https://github.com/5SMNOONMS5/XcodeSyncTools.git 42 | 43 | # Step 2: Change working directory 44 | cd XcodeSyncTools 45 | 46 | # Step 3: Run startup script 47 | sh xcode-sync.sh -s 48 | ``` 49 | 50 | Don't download it directory, because I embeded [fsevents-tools](https://github.com/ggreer/fsevents-tools) via [git Submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodule) 51 | 52 | ## More details 53 | 54 | ```bash 55 | sh xcode-sync.sh -h 56 | ``` 57 | 58 | ## Keyword 59 | 60 | ### II 61 | 62 | Type **II** for initialization 63 | 64 | ![](Imgs/demo-ii.png) 65 | 66 | ### FF 67 | 68 | Type **FF** for FIXME 69 | 70 | ![](Imgs/demo-ff.png) 71 | 72 | ### MM 73 | 74 | Type **MM** for Mark 75 | 76 | ![](Imgs/demo-mm.png) 77 | 78 | ### VV 79 | 80 | Type **VV** for View Life Cycle 81 | 82 | ![](Imgs/demo-vv.png) 83 | -------------------------------------------------------------------------------- /Templates/File Templates/Common/Singlthon Class.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/Common/Singlthon Class.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Templates/File Templates/Common/Singlthon Class.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/Common/Singlthon Class.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Templates/File Templates/Common/Singlthon Class.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Kind 6 | Xcode.IDEFoundation.TextSubstitutionFileTemplateKind 7 | Description 8 | Singlthon file 9 | Summary 10 | Easy way to create Singlthon file 11 | SortOrder 12 | 30 13 | AllowedTypes 14 | 15 | public.swift-source 16 | 17 | DefaultCompletionName 18 | File 19 | MainTemplateFile 20 | ___FILEBASENAME___.swift 21 | 22 | 23 | -------------------------------------------------------------------------------- /Templates/File Templates/Common/Singlthon Class.xctemplate/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // ___COPYRIGHT___ 7 | // 8 | 9 | import Foundation 10 | 11 | public final class ___FILEBASENAMEASIDENTIFIER___ { 12 | 13 | static let share = ___FILEBASENAMEASIDENTIFIER___() 14 | 15 | /// prevent initial from other 16 | private override init() { } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UICollectionView+Xib.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/UI/UICollectionView+Xib.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Templates/File Templates/UI/UICollectionView+Xib.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/UI/UICollectionView+Xib.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Templates/File Templates/UI/UICollectionView+Xib.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DefaultCompletionName 6 | MyCollectionView 7 | Description 8 | UICollectionView with build-in Xib file 9 | Kind 10 | Xcode.IDEKit.TextSubstitutionFileTemplateKind 11 | Options 12 | 13 | 14 | Description 15 | The name of the UICollectionView to create 16 | Identifier 17 | viewName 18 | Name 19 | New UICollectionView Name: 20 | NotPersisted 21 | 22 | Required 23 | 24 | Type 25 | text 26 | 27 | 28 | Default 29 | ___VARIABLE_viewName:identifier___ 30 | Identifier 31 | productName 32 | Type 33 | static 34 | 35 | 36 | Default 37 | ___VARIABLE_viewName:identifier___CollectionView 38 | Description 39 | The view name 40 | Identifier 41 | interactorName 42 | Name 43 | Interactor Name: 44 | Required 45 | 46 | Type 47 | static 48 | 49 | 50 | Platforms 51 | 52 | com.apple.platform.iphoneos 53 | 54 | SortOrder 55 | 2 56 | Summary 57 | Easy generates a new UICollectionView with Cell xib 58 | 59 | 60 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UICollectionView+Xib.xctemplate/___FILEBASENAME___CollectionLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // ___COPYRIGHT___ 7 | // 8 | 9 | import UIKit 10 | 11 | final class ___FILEBASENAMEASIDENTIFIER___: UICollectionViewLayout { 12 | 13 | public override init() { 14 | super.init() 15 | print("SSSSCollectionLayout") 16 | } 17 | 18 | required public init?(coder aDecoder: NSCoder) { 19 | super.init(coder: aDecoder) 20 | fatalError("init(coder:) has not been implemented") 21 | } 22 | 23 | fileprivate var cached = [UICollectionViewLayoutAttributes]() 24 | 25 | // <# First step #> 26 | // Return the size of all the content in the collection view 27 | override var collectionViewContentSize: CGSize { 28 | return CGSize(width: 100, height: 100) 29 | } 30 | 31 | // <# Second Step #> 32 | // Perform whatever calculations are needed to determine the position of the cells and views in the layout 33 | override func prepare() { 34 | print("prepare ") 35 | } 36 | 37 | // <# Third Step #> 38 | // 39 | // Tip 40 | // Need to override layoutAttributesForElements(in:), which the collection view calls after prepare() to determine which items are visible in the given rect. 41 | // 42 | // Return all attributes in the cache whose frame intersects with the rect passed to the method 43 | override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 44 | return cached.filter { attributes in 45 | return attributes.frame.intersects(rect) 46 | } 47 | } 48 | 49 | // <# Fouth Step #> 50 | // Returns the layout attributes for the item at the specified index path. 51 | override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { 52 | return cached[indexPath.item] 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UICollectionView+Xib.xctemplate/___FILEBASENAME___CollectionView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // ___COPYRIGHT___ 7 | // 8 | import UIKit 9 | 10 | final class ___FILEBASENAMEASIDENTIFIER___: UICollectionView { 11 | 12 | fileprivate var contents: [String] = Array(repeating: "ssssssss", count: 30) 13 | 14 | override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { 15 | super.init(frame: frame, collectionViewLayout: layout) 16 | self.setup() 17 | } 18 | 19 | convenience init(frame: CGRect, expandWidth: CGFloat, collapsedWidth: CGFloat) { 20 | 21 | let layout = ___VARIABLE_viewName___CollectionLayout() 22 | self.init(frame: frame, collectionViewLayout: layout) 23 | self.setup() 24 | } 25 | 26 | required init?(coder aDecoder: NSCoder) { 27 | super.init(coder: aDecoder) 28 | fatalError("init(coder:) has not been implemented") 29 | } 30 | 31 | fileprivate func setup() { 32 | 33 | self.register(gc_Nib(name: "___VARIABLE_viewName___CollectionViewCell"), forCellWithReuseIdentifier: ___VARIABLE_viewName___CollectionViewCell.className) 34 | self.backgroundColor = .blue 35 | 36 | self.decelerationRate = UIScrollViewDecelerationRateFast 37 | self.alwaysBounceHorizontal = true 38 | self.showsVerticalScrollIndicator = false 39 | self.showsHorizontalScrollIndicator = false 40 | 41 | super.delegate = self 42 | super.dataSource = self 43 | } 44 | } 45 | 46 | // ****************************************** 47 | // 48 | // MARK: - UICollectionViewDelegate 49 | // 50 | // ****************************************** 51 | extension ___FILEBASENAMEASIDENTIFIER___: UICollectionViewDelegate { 52 | 53 | func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { 54 | } 55 | 56 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 57 | print(indexPath.row) 58 | } 59 | 60 | func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { 61 | print(indexPath.row) 62 | } 63 | } 64 | 65 | // ****************************************** 66 | // 67 | // MARK: - UICollectionViewDataSource 68 | // 69 | // ****************************************** 70 | extension ___FILEBASENAMEASIDENTIFIER___: UICollectionViewDataSource { 71 | 72 | func numberOfSections(in collectionView: UICollectionView) -> Int { 73 | return 1 74 | } 75 | 76 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 77 | return self.contents.count 78 | } 79 | 80 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 81 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ___VARIABLE_viewName___CollectionViewCell.className, for: indexPath as IndexPath) as! ___VARIABLE_viewName___CollectionViewCell 82 | 83 | return cell 84 | } 85 | } 86 | 87 | 88 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UICollectionView+Xib.xctemplate/___FILEBASENAME___CollectionViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // ___COPYRIGHT___ 7 | // 8 | 9 | import UIKit 10 | 11 | class ___FILEBASENAMEASIDENTIFIER___: UICollectionViewCell { 12 | 13 | @IBOutlet weak var lblTitle: UILabel! 14 | 15 | override func awakeFromNib() { 16 | super.awakeFromNib() 17 | // Initialization code 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UICollectionView+Xib.xctemplate/___FILEBASENAME___CollectionViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UITableView.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/UI/UITableView.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Templates/File Templates/UI/UITableView.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/UI/UITableView.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Templates/File Templates/UI/UITableView.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Kind 6 | Xcode.IDEFoundation.TextSubstitutionFileTemplateKind 7 | Description 8 | Singlthon file 9 | Summary 10 | Easy way to create Singlthon file 11 | SortOrder 12 | 30 13 | AllowedTypes 14 | 15 | public.swift-source 16 | 17 | DefaultCompletionName 18 | EnterYourNameHere 19 | MainTemplateFile 20 | ___FILEBASENAME___.swift 21 | 22 | 23 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UITableView.xctemplate/___FILEBASENAME___TableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // ___COPYRIGHT___ 7 | // 8 | 9 | import UIKit 10 | 11 | // <# Important #> 12 | // If you have your own extension, kindly delete me :( 13 | public extension NSObject { 14 | 15 | /// Get class name 16 | /// 17 | /// EX: 18 | /// 19 | /// ```swift 20 | /// MyClass.className //=> "MyClass" 21 | /// ``` 22 | class var className: String { 23 | return String(describing: self) 24 | } 25 | } 26 | 27 | final class ___FILEBASENAMEASIDENTIFIER___: UITableView { 28 | 29 | fileprivate var contents: [String] = { 30 | var _contents: [String] = Array(repeating: "asdasdasdasdasdasdasdasdasd", count: 20) 31 | /// <# Notice #> For testing dynamic cell height, replace your own data 32 | _contents += Array(repeating: "我愛一條材我愛一條材我愛一條材我愛一條材我愛一條材我愛一條材我愛一條材", count: 5) 33 | _contents += Array(repeating: "HolaHolaHolaHolaHolaHolaHolaHolaHolaHolaHolaHolaHolaHola", count: 5) 34 | _contents += Array(repeating: "여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요여보세요", count: 5) 35 | return _contents 36 | }() 37 | 38 | fileprivate var rowDefaultSelected: Int = 0 39 | 40 | override init(frame: CGRect, style: UITableViewStyle) { 41 | super.init(frame: frame, style: style) 42 | self.setup() 43 | } 44 | 45 | required init?(coder aDecoder: NSCoder) { 46 | super.init(coder: aDecoder) 47 | self.setup() 48 | } 49 | 50 | convenience init(contents: [String]) { 51 | self.init(frame: .zero, style: .plain) 52 | self.contents = contents 53 | } 54 | 55 | fileprivate func setup() { 56 | self.register(UINib(nibName: "___FILEBASENAMEASIDENTIFIER___Cell", bundle: nil), forCellReuseIdentifier: ___FILEBASENAMEASIDENTIFIER___Cell.className) 57 | 58 | // <# Important #> If you don't want use xib, remove xib first then uncommment below code 59 | // self.register(___FILEBASENAMEASIDENTIFIER___Cell.self, forCellReuseIdentifier: ___FILEBASENAMEASIDENTIFIER___Cell.className) 60 | 61 | super.delegate = self 62 | super.dataSource = self 63 | self.separatorStyle = .none 64 | self.backgroundColor = .clear 65 | self.estimatedRowHeight = 44.0 66 | self.showsHorizontalScrollIndicator = false 67 | self.showsVerticalScrollIndicator = false 68 | self.rowHeight = UITableViewAutomaticDimension 69 | } 70 | } 71 | 72 | // ****************************************** 73 | // 74 | // MARK: - UITableViewDelegate 75 | // 76 | // ****************************************** 77 | extension ___FILEBASENAMEASIDENTIFIER___: UITableViewDelegate { 78 | 79 | func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 80 | if indexPath.row == rowDefaultSelected { 81 | tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none) 82 | /// meaning already selected, then don't need extra flag to detect 83 | rowDefaultSelected = -1 84 | } 85 | } 86 | 87 | // <# Important #> uncomment below code will effect <# self.rowHeight #> and <# estimatedRowHeight #> 88 | // func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 89 | // return 44.0 90 | // } 91 | 92 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 93 | 94 | } 95 | 96 | func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { 97 | 98 | } 99 | } 100 | 101 | // ****************************************** 102 | // 103 | // MARK: - UITableViewDataSource 104 | // 105 | // ****************************************** 106 | extension ___FILEBASENAMEASIDENTIFIER___: UITableViewDataSource { 107 | 108 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 109 | return self.contents.count 110 | } 111 | 112 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 113 | 114 | let cell = tableView.dequeueReusableCell(withIdentifier: ___FILEBASENAMEASIDENTIFIER___Cell.className, for: indexPath) as! ___FILEBASENAMEASIDENTIFIER___Cell 115 | cell.lblContent.text = self.contents[indexPath.row] 116 | return cell 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UITableView.xctemplate/___FILEBASENAME___TableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // ___COPYRIGHT___ 7 | // 8 | 9 | import UIKit 10 | 11 | final class ___FILEBASENAMEASIDENTIFIER___: UITableViewCell { 12 | 13 | @IBOutlet weak var lblContent: UILabel! 14 | 15 | var gradient: CAGradientLayer = { 16 | let _gradient: CAGradientLayer = CAGradientLayer() 17 | 18 | let colors = [UIColor(red:0.13, green:0.60, blue:0.59, alpha:0.0).cgColor, 19 | UIColor(red:0.13, green:0.60, blue:0.59, alpha:0.4).cgColor, 20 | UIColor(red:0.13, green:0.60, blue:0.59, alpha:0.0).cgColor] 21 | _gradient.colors = colors 22 | _gradient.locations = [0.0, 0.5, 1.0] 23 | _gradient.startPoint = CGPoint(x: 0.0, y: 0.5) 24 | _gradient.endPoint = CGPoint(x: 1.0, y: 0.5) 25 | _gradient.opacity = 1 26 | 27 | return _gradient 28 | }() 29 | 30 | override func awakeFromNib() { 31 | super.awakeFromNib() 32 | self.setup() 33 | // Initialization code 34 | } 35 | 36 | override func setSelected(_ selected: Bool, animated: Bool) { 37 | super.setSelected(selected, animated: animated) 38 | // Configure the view for the selected state 39 | 40 | let isContains = self.layer.sublayers?.contains(self.gradient) ?? false 41 | 42 | if selected && !isContains { 43 | gradient.frame = self.bounds 44 | self.layer.addSublayer(gradient) 45 | } else if !selected && isContains { 46 | self.gradient.removeFromSuperlayer() 47 | } 48 | } 49 | 50 | fileprivate func setup() { 51 | self.selectionStyle = .none 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UITableView.xctemplate/___FILEBASENAME___TableViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView+Xib.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/UI/UIView+Xib.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView+Xib.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/UI/UIView+Xib.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView+Xib.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | DefaultCompletionName 7 | MyView 8 | Description 9 | UIView with build-in Xib file 10 | Kind 11 | Xcode.IDEKit.TextSubstitutionFileTemplateKind 12 | Options 13 | 14 | 15 | Description 16 | The name of the view to create 17 | Identifier 18 | viewName 19 | Name 20 | New View Name: 21 | NotPersisted 22 | 23 | Required 24 | 25 | Type 26 | text 27 | 28 | 29 | Default 30 | ___VARIABLE_viewName:identifier___ 31 | Identifier 32 | productName 33 | Type 34 | static 35 | 36 | 37 | Default 38 | ___VARIABLE_viewName:identifier___View 39 | Description 40 | The view name 41 | Identifier 42 | interactorName 43 | Name 44 | Interactor Name: 45 | Required 46 | 47 | Type 48 | static 49 | 50 | 51 | Platforms 52 | 53 | com.apple.platform.iphoneos 54 | 55 | SortOrder 56 | 2 57 | Summary 58 | Easy generates a new view with xib owner. 59 | 60 | 61 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView+Xib.xctemplate/___FILEBASENAME___View.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // ___COPYRIGHT___ 7 | // 8 | import UIKit 9 | 10 | class ___FILEBASENAMEASIDENTIFIER___: UIView { 11 | 12 | @IBOutlet weak var viewContent: UIView! 13 | 14 | override init(frame: CGRect) { 15 | super.init(frame: frame) 16 | self.setupXib() 17 | self.setupUI() 18 | } 19 | 20 | required init?(coder aDecoder: NSCoder) { 21 | super.init(coder: aDecoder) 22 | self.setupXib() 23 | self.setupUI() 24 | } 25 | 26 | convenience init () { 27 | self.init(frame: .zero) 28 | } 29 | 30 | private func setupXib() { 31 | Bundle.main.loadNibNamed("___FILEBASENAMEASIDENTIFIER___", owner: self, options: nil) 32 | self.viewContent.frame = self.bounds 33 | self.addSubview(self.viewContent) 34 | } 35 | 36 | 37 | private func setupUI() { 38 | 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView+Xib.xctemplate/___FILEBASENAME___View.xib: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/UI/UIView.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Templates/File Templates/UI/UIView.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Kind 6 | Xcode.IDEFoundation.TextSubstitutionFileTemplateKind 7 | Description 8 | Singlthon file 9 | Summary 10 | Easy way to create Singlthon file 11 | SortOrder 12 | 30 13 | AllowedTypes 14 | 15 | public.swift-source 16 | 17 | DefaultCompletionName 18 | SwiftPHUIView 19 | MainTemplateFile 20 | ___FILEBASENAME___.swift 21 | 22 | 23 | -------------------------------------------------------------------------------- /Templates/File Templates/UI/UIView.xctemplate/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // ___COPYRIGHT___ 7 | // 8 | import UIKit 9 | 10 | final class ___FILEBASENAMEASIDENTIFIER___: UIView { 11 | 12 | override init(frame: CGRect) { 13 | super.init(frame: frame) 14 | self.setupUI() 15 | } 16 | 17 | required init?(coder aDecoder: NSCoder) { 18 | super.init(coder: aDecoder) 19 | self.setupUI() 20 | } 21 | 22 | convenience init () { 23 | self.init(frame: .zero) 24 | } 25 | 26 | private func setupUI() { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Tutorials/README_CS.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Tutorials/README_CS_CN.md: -------------------------------------------------------------------------------- 1 | 2 | # 程式碼片段 製作教學 3 | 4 | ## I 5 | 6 | * 選好程式碼,然後準備 代碼佔位符 7 | 8 | ```swift 9 | <# name #> 10 | ``` 11 | 12 | ![](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_cs1.gif) 13 | 14 | ## II 15 | 16 | * 然後幫程式碼加上代碼佔位符,這麼做是因為之後你可以使用 tab 鍵在代碼佔位符互相跳來跳去,這樣省去用滑鼠的時間。 17 | 18 | ![](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_cs2.gif) 19 | 20 | ### III 21 | 22 | * 拖到 xcode 裡面,然後輸入 shortcut,方便之後跳出來,如果這時候有開啟 [fsevents-tools](https://github.com/ggreer/fsevents-tools),同時也會更動這專案底下的檔案。 23 | 24 | ![](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_cs3.gif) 25 | 26 | * 因果圖 27 | 28 | > 只有在 completion shortcut 的欄位才會被搜尋到 29 | 30 | ![](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_cs1-1.png) 31 | ![](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_cs1-2.png) 32 | 33 | ### IV 34 | 35 | * 打下您剛剛輸入的 shortcut,然後使用 tab 鍵跳代碼佔位符 36 | 37 | ![](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_cs4.gif) -------------------------------------------------------------------------------- /Tutorials/README_T.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5SMNOONMS5/XcodeSyncTools/a07616c1b7108797c84992c0636ad5afc076440d/Tutorials/README_T.md -------------------------------------------------------------------------------- /Tutorials/README_T_CN.md: -------------------------------------------------------------------------------- 1 | 2 | # 程式碼樣板 製作教學 3 | 4 | ## I - 大致流程 5 | 6 | ![.](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_t4.gif) 7 | 8 | ## II - 路徑 9 | 10 | ``` 11 | /Users/stephenchen/Library/Developer/Xcode 12 | ``` 13 | 14 | ![](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_t1.png) 15 | 16 | ## III - 目錄結構 17 | 18 | ![.](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_t2.png) 19 | 20 | * 這裡透過 TableViewHeader 跟 Cell 來比喻。 21 | 22 | > 後綴名一定要是 **xctemplate** 23 | 24 | ## IV - 資料夾結構 25 | 26 | ![.](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_t3.png) 27 | 28 | | 檔案名稱 | 描敘 | 29 | |--:|---| 30 | | TemplateIcon.png | 48 * 48 | 31 | | TemplateIcon@2x.png | 96 * 96 | 32 | | TemplateInfo.plist | 設定參數,下方會描敘更多 | 33 | | \_\_\_FILEBASENAME___.xib | 客製化的 xib | 34 | | \_\_\_FILEBASENAME___.swift | 客製化的 swift | 35 | 36 | ## V - Plist 的參數 37 | 38 | ### Plist 一覽 39 | 40 | ![.](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_t6.png) 41 | 42 | ### Plist 的參數是直接影響**創建的過程**,打個比方,動態的輸入檔案名稱的時候 43 | 44 | ![.](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/create_file.gif) 45 | 46 | ### Plist 參數介紹 47 | 48 | ![.](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_t7.png) 49 | 50 | ## VI - 源碼變數 ~~> 產生後的檔案 51 | 52 | ![.](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/Imgs/tu_t5.png) 53 | 54 | ### 源碼變數介紹,假設我開了一個新專案,名稱叫做 MyProject,透過產生了一個 test.swift 的檔案。 55 | 56 | | 參數 | 顯示 | 備註 | 57 | |--:|---|---| 58 | | \_\_\_YEAR___ | 2018 | | 59 | | \_\_\_TIME___ | 9:36 PM | | 60 | | \_\_\_COPYRIGHT___ | 版權說明 | | 61 | | \_\_\_DATE___ | 創建這檔案的時間 | | 62 | | \_\_\_ORGANIZATIONNAME___ | 創建者的姓名 | | 63 | | \_\_\_FILEBASENAME___ | Test.swift | **沒有**後綴名 | 64 | | \_\_\_FILENAME___ | Test | **有**後綴名 | 65 | | \_\_\_FILEBASENAMEASIDENTIFIER___ | Test | **沒有**後綴名,任何在 c 語言裡面非法的變量名稱(Ex: $%),都會被下底線替換掉 | 66 | | \_\_\_USERNAME___ | stephenchen | 當前電腦登入者的姓名 | 67 | | \_\_\_FULLUSERNAME___ | StephenChen | 當前電腦登入者的姓名(全名) | 68 | | \_\_\_PROJECTNAME___ | MyProject | | 69 | | \_\_\_PROJECTNAMEASIDENTIFIER___ | MyProject | 當前項目的名稱,任何在 c 語言裡面非法的變量名稱(Ex: $%),都會被**下劃線**替換掉 | 70 | | \_\_\_PROJECTNAMEASXML___ | MyProject | 當前項目的名稱,但是任何特殊字串都會被替換成合格的 XML 字串(EX: < 跟 > 被分別替換為 < 還有 &rt; | 71 | | \_\_\_PACKAGENAME___ | MyProject | 通常跟項目名稱會是一樣的 | 72 | | \_\_\_PACKAGENAMEASIDENTIFIER___ | MyProject | 通常跟項目名稱會是一樣的,任何在 c 語言裡面非法的變量名稱(Ex: $%),都會被**下劃線**替換掉 | 73 | | \_\_\_PACKAGENAMEASXML___ | MyProject | 通常跟項目名稱會是一樣的,但是任何特殊字串都會被替換成合格的 XML 字串(EX: < 跟 > 被分別替換為 < 還有 &rt; | 74 | | \_\_\_UUIDASIDENTIFIER___ | 4C046C78-743D-4E52-B59F-E99711C4D3A5 | UUID 通用唯一標識符 (A universally unique identifier) | 75 | | \_\_\_UUIDASIDENTIFIER___ | 4C046C78-743D-4E52-B59F-E99711C4D3A5 | UUID 通用唯一標識符,任何在 c 語言裡面非法的變量名稱(Ex: $%),都會被**下劃線**替換掉。| 76 | | \_\_\_VARIABLE_NameOfVariable___ | Test | 這個值是在創建檔案的時候所輸入的檔名,比如我剛剛輸入 Test,我在源碼寫成 \_\_\_VARIABLE_NameOfVariable___ViewController,那結果就會是 TestViewController | 77 | 78 | ## Reference 79 | 80 | [Use-your-loaf](https://useyourloaf.com/blog/creating-custom-xcode-project-templates/) 81 | 82 | [Xcode 4 Template Documentation](http://www.learn-cocos2d.com/store/xcode4-template-documentation) 83 | -------------------------------------------------------------------------------- /xcode-sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | version="0.5.0" 4 | 5 | #default config 6 | 7 | # change to your own (ex: gitub, bitcket....etc) 8 | path_source_url="git@github.com:5SMNOONMS5/XcodeSyncTools.git" 9 | 10 | src1=${HOME}/Library/Developer/Xcode/Templates 11 | src1_local=Templates 12 | 13 | src2=${HOME}/Library/Developer/Xcode/UserData/CodeSnippets 14 | src2_local=CodeSnippets 15 | 16 | # I will make colorful console output in the future 17 | declare -a colors 18 | colors[2]=33 # yellow text 19 | colors[4]=32 # green text 20 | colors[8]=34 # blue text 21 | colors[16]=36 # cyan text 22 | colors[32]=35 # purple text 23 | colors[64]="33m\033[7" # yellow background 24 | colors[128]="32m\033[7" # green background 25 | colors[256]="34m\033[7" # blue background 26 | colors[512]="36m\033[7" # cyan background 27 | colors[1024]="35m\033[7" # purple background 28 | colors[2048]="31m\033[7" # red background (won with default target) 29 | 30 | # check path 31 | check() { 32 | # Thanks to https://askubuntu.com/questions/648577/copying-files-from-directories-having-spaces-in-its-name 33 | echo $(basename $1) 34 | if [ ! -d "$1" ]; then 35 | echo "$(basename $1) path not found, create a new one" 36 | else 37 | echo "$(basename $1) already exist, duplicate a $(basename $1)_old folder" 38 | if [ -d "$1_old" ]; then 39 | echo "has $1_old remove old version first" 40 | rm -rf "$1_old" 41 | fi 42 | mv "$1" "$1_old" 43 | fi 44 | mkdir "$1" 45 | } 46 | 47 | # Usage info 48 | usage() { 49 | cat <