修改xcode初始生成代码
xcode在新建新的工程的时候会默认生成一份代码,例如新建一个c++工程,其初始的代码如下:
#include <iostream>
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return ;
}
这本无可厚非,当我们第一次用c++的时候非常友好的代码。Hello World! 只是当写算法题需要大量新建工程时,我们可能希望面对的不是这样一份几乎没用的代码,我们希望的是能够已经写了足够多的库文件或者一些初始注释
啥的。因此此时我们就需要来修改这个初始的文件。
我们找到这个文件的位置: /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate/TemplateInfo.plist
语言类似html风格,我们找到我们需要修改的地方进行修改就好了。主要注意的是它用的是html的语法,因此例如 < > " & 等字符需要转义 例如< 变成> 等等。

最后说一下,上面的几个//的注释不在这个文件里修改。不过也在附近的文件里。如果你觉得看着这个初始的注释信息不顺眼也可以自己去探寻修改一下。
以及xcode更新的时候这个文件可能又会变成初始,因此改完之后最好备份一下。就酱~
另附我修改后的源文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string>
<key>Identifier</key>
<string>com.apple.dt.unit.commandLineTool</string>
<key>Ancestors</key>
<array>
<string>com.apple.dt.unit.base</string>
<string>com.apple.dt.unit.osxBase</string>
</array>
<key>Concrete</key>
<true/>
<key>SortOrder</key>
<integer>50</integer>
<key>Description</key>
<string>This template creates a command-line tool.</string>
<key>Targets</key>
<array>
<dict>
<key>ProductType</key>
<string>com.apple.product-type.tool</string>
<key>TargetIdentifier</key>
<string>com.apple.dt.commandLineToolTarget</string>
<key>BuildPhases</key>
<array>
<dict>
<key>Class</key>
<string>Sources</string>
</dict>
<dict>
<key>Class</key>
<string>Frameworks</string>
</dict>
<dict>
<key>Class</key>
<string>CopyFiles</string>
<key>DstPath</key>
<string>/usr/share/man/man1/</string>
<key>DstSubfolderSpec</key>
<string>0</string>
<key>RunOnlyForDeploymentPostprocessing</key>
<string>YES</string>
</dict>
</array>
</dict>
</array>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>commandLineType</string>
<key>Name</key>
<string>Language:</string>
<key>Description</key>
<string>The primary implementation language for the command-line tool</string>
<key>Default</key>
<string>Swift</string>
<key>Type</key>
<string>popup</string>
<key>Values</key>
<array>
<string>Swift</string>
<string>Objective-C</string>
<string>C++</string>
<string>C</string>
</array>
<key>Units</key>
<dict>
<key>C</key>
<dict>
<key>Nodes</key>
<array>
<string>main.c:comments</string>
<string>main.c:include</string>
<string>main.c:main:content</string>
</array>
<key>Definitions</key>
<dict>
<key>main.c:include</key>
<string>#include <stdio.h>
</string>
<key>main.c:main:content</key>
<string>// insert code here...
printf("Hello, World!\n");
return 0;
</string>
</dict>
</dict>
<key>C++</key>
<dict>
<key>Nodes</key>
<array>
<string>main.cpp:comments</string>
<string>main.cpp:include</string>
<string>main.cpp:main:content</string>
</array>
<key>Definitions</key>
<dict>
<key>main.cpp:include</key>
<string>#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
#include <queue> typedef long long ll;
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define rep2(i,a,b) for (int i = (a); i >= (b); --i) using namespace std; const int N = 10010;
int ans, n , m, a[N]; </string>
<key>main.cpp:main:content</key>
<string>
cin >> n >> m;
rep (i, 1, n){
scanf("%d",&a[i]);
} ans = 0; cout << ans << endl;
</string>
</dict>
</dict>
<key>Objective-C</key>
<dict>
<key>Nodes</key>
<array>
<string>main.m:comments</string>
<string>main.m:include</string>
<string>main.m:main:content</string>
</array>
<key>Definitions</key>
<dict>
<key>main.m:include</key>
<string>#import <Foundation/Foundation.h>
</string>
<key>main.m:main:content</key>
<string>@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
}
return 0;
</string>
</dict>
</dict>
<key>Swift</key>
<dict>
<key>Project</key>
<dict>
<key>Configurations</key>
<dict>
<key>Debug</key>
<dict>
<key>SWIFT_OPTIMIZATION_LEVEL</key>
<string>-Onone</string>
</dict>
</dict>
</dict>
<key>Targets</key>
<array>
<dict>
<key>SharedSettings</key>
<dict>
<key>SWIFT_VERSION</key>
<string>___DEFAULTTOOLCHAINSWIFTVERSION___</string>
</dict>
</dict>
</array>
<key>Nodes</key>
<array>
<string>main.swift:comments</string>
<string>main.swift:include</string>
<string>main.swift:main:content</string>
</array>
<key>Definitions</key>
<dict>
<key>main.swift:include</key>
<string>import Foundation
</string>
<key>main.swift:main</key>
<dict>
<key>Beginning</key>
<string></string>
<key>End</key>
<string></string>
</dict>
<key>main.swift:main:content</key>
<string>print("Hello, World!")
</string>
</dict>
</dict>
</dict>
</dict>
</array>
<key>Definitions</key>
<dict>
<key>*:main</key>
<dict>
<key>Beginning</key>
<string>int main() {</string>
<key>End</key>
<string>}</string>
<key>Indent</key>
<integer>1</integer>
</dict>
</dict>
</dict>
</plist>
修改xcode初始生成代码的更多相关文章
- 设置 Xcode 自动生成代码片段
一.什么是代码片段 当在Xcode中输入dowhile并回车后,Xcode会出现下图所示的提示代码: 这就是代码片段,目的是使程序员以最快的速度输入常用的代码片段,提高编程效率.该功能是从Xcode4 ...
- xcode自动生成代码片段
一.什么是代码片段 当在Xcode中输入dowhile并回车后,Xcode会出现下图所示的提示代码: 这就是代码片段,目的是使程序员以最快的速度输入常用的代码片段,提高编程效率.该功能是从Xcode4 ...
- 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UITableViewCell注册(填写)重用标识符:identifier.必须要代码方法中的标识符一致.
CHENYILONG Blog 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UI ...
- EA修改生成代码的表头注释
我们在做项目的过程中,每个代码文件都应有此文件的注释,比如说作者,文件说明等.但是如果用EA生成的代码文件的注释是纯英文的,而且有些不是我们需要显示的注释,有些我们需要显示的它又不具备.那么我们就可以 ...
- python之gui-tkinter可视化编辑界面 自动生成代码
首先提供资源链接 http://pan.baidu.com/s/1kVLOrIn#list/path=%2F
- 使用Mybatis Generator自动生成代码
MyBatis Generator(MBG)是MyBatis MyBatis 和iBATIS的代码生成器.它将为所有版本的MyBatis以及版本2.2.0之后的iBATIS版本生成代码.它将内省数据库 ...
- mybatis Generator生成代码及使用方式
本文原创,转载请注明:http://www.cnblogs.com/fengzheng/p/5889312.html 为什么要有mybatis mybatis 是一个 Java 的 ORM 框架,OR ...
- 动态生成一个设定好特殊样式的Tlabel,快速生成代码
动态生成一个设定好特殊样式的Tlabel,快速生成代码: 1.自己先在可视化界面设定一个Label,像这样: 2.选择label,快捷键ctrl+C 复制,粘贴带代码编辑器去,会生成一段这样的窗体代码 ...
- MyBatis自动生成代码示例
在项目中使用到mybatis时,都会选择自动生成实体类,Mapper,SqlMap这三个东东. 手头上在用的又不方便,找了下网上,其实有很多文章,但有些引用外部文件时不成功,也不方便,所以重新整理了下 ...
随机推荐
- jenkins外网slave配置
背景: 客户提供了测试服务器,但不能外网直连需要通过windows跳板进行进行连接. 方案设定将windows跳板机配置为远程slave节点. 技术支持: jenkins-slave windows ...
- JAVA入门[22]—thymeleaf
一.thymeleaf官网 官网:https://www.thymeleaf.org/index.html doc:https://www.thymeleaf.org/documentation.ht ...
- Jsoup教程jsoup开发指南,jsoup中文使用手册,jsoup中文文档
jsoup 是一款Java 的HTML解析器,可直接解析某个URL地址.HTML文本内容.它提供了一套非常省力的API,可通过DOM,CSS以及类似于jQuery的操作方法来取出和操作数据. jsou ...
- 将域名转移到 Google Domains
之前存放域名用过 Godaddy.Dynadot.Namesilo 也有阿里云(万网)和腾讯云(新网),这回就用 Google Domains 啦! 话说 Google Domains 早已是 201 ...
- Java中使用POI读取大的Excel文件或者输入流时发生out of memory异常参考解决方案
注意:此参考解决方案只是针对xlsx格式的excel文件! 背景 前一段时间遇到一种情况,服务器经常宕机,而且没有规律性,查看GC日志发生了out of memory,是堆溢出导致的,分析了一下堆的d ...
- [补档]暑假集训D8总结
%dalao 今天有两位大佬来讲课,meaty来讲了Catalan(本来说好的莫比乌斯反演呢),聪聪来讲Splay呢 至于听课笔记= =,没来得及记= = 不过好不想上树啊,上了树就下不来了 考试 仍 ...
- 双向循环链表(C语言描述)(三)
代码清单 // linkedlist.h #ifndef __LINKEDLIST_H__ #define __LINKEDLIST_H__ #include <assert.h> #in ...
- 关于ajax请求rul时意外结束符号
最终解决办法:web.config 中添加节点 <webServices> <protocols> <add name="HttpPos ...
- 小兴趣:用python生成excel格式座位表
脚本分两个文件: 1.生成二维随机列表:GenerateLocaltion.py 2.将列表导入excel文件:CreateExcel.py 先上GenerateLocaltion.py: impor ...
- Java restful web service 开发入门
可用的框架有不少,我用的是jersey. 直接上代码,其实,如果你会web service 这个restful的就很好理解了,自己跑一遍就OK了 用到的类 User.java package demo ...