preface

Xcode is divided into system templates and custom templates. The benefits of templates are as follows:

1, save repeated code writing time

2. Standardize the code to improve the readability of the code

3. Reduce unnecessary time spent writing code,XIB or modifying related configurations

The iOS template path is as follows:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates
Copy the code

The path for customizing a template is as follows:

~/Library/Developer/Xcode/Templates
Copy the code

Custom Templates

folder

The terminal opens the custom template path

open ~/Library/Developer/Xcode
Copy the code

Create folders in the Xcode directory

Templates-Custom Templates-MVC.xctemplate
Copy the code

TemplateInfo file

<? xml version="1.0" encoding="UTF-8"? > <! DOCTYPE plist PUBLIC"- / / / / DTD PLIST Apple 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>
Copy the code

MVC template file

https://github.com/jackyshan/XcodeiOSTemplate
Copy the code

Xcode New – Select template

command+n

Enter the Module Name

Create folders and files

Delete the -remove Reference folder and re-import the folder TY_MeiyanSP and select Create Groups

The MVC template is imported.