I. Overview
- The project template is a certain item selected when creating a project, Xcode will generate a fixed format project based on the selected item
- This article takes xcode's Command Line Tool project as an example to introduce how to modify the xcode template
Two Xcode template modification
2.1 Main.m template modification
-
In the application, find Xcode, right click "Show Package Contents"
-
打开“/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate“
-
Use xcode to open the TemplateInfo.plist under the folder
-
If you modify the content of the template, open it with a "text editor" and search for "Hello, World"
2.2 Modify class files (.h files and .m files)
-
In the application, find Xcode, right click "Show Package Contents"
-
打开“/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Source/Cocoa Class.xctemplate/NSObjectObjective-C”路径
___FILEBASENAME___.h——头文件了 ___FILEBASENAME___.m——类实现
-
_FILEBASENAME_.h
//___FILEHEADER___ ___IMPORTHEADER_cocoaSubclass___ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaSubclass___ @end NS_ASSUME_NONNULL_END
-
_ FILEBASENAME_ .m class implementation file
//___FILEHEADER___ #import "___FILEBASENAME___.h" @implementation ___FILEBASENAMEASIDENTIFIER___ @end