用Xcode配置完美ACMer环境

前言

​ 作为\(ACMer\),需求大致为强大的文本编辑功能\((VIM)\),便捷的文件模版功能以及多文件编译功能。\(vscode\)虽然强大,但是与集成\(IDE\)相比其缺点也很明显,就是没有完美的\(Debug\)功能。而\(Xcode\)刚好有此功能,但是在其他方面却显得有些笨拙,经过在网上探查,逐步实现了\(Xcode+vim+多文件编译 +自定义模版\)等功能。下面就来一一介绍如何配置。

万能头文件

  • 打开\(Finder\)

  • 按快捷键:\(Command+Shift+G\)。

  • 输入路径:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
  • 创建名为"bits"的文件夹

  • 创建名为"stdc++.h"的文件

  • 文件中写入以下代码:

// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
  • 保存退出即可。

Vim插件

  • 首先确认\(Xcode\)处于关闭状态
  • 因为\(Vim\)插件属于第三方软件,所以需要给其注册一个证书:
# 下载注册软件
git clone https://github.com/slegetank/ResignXcode.git # 进入安装目录
cd ResignXcode # 运行注册程序
python2.7 ResignXcode.py
  • 等待,可能时间比较长
  • 安装\(Vim\)插件:
# 确认 Xcode 指向 /Applications/Xcode.app/Contents/Developer
xcode-select -p # 下载 XVim2
git clone https://github.com/XVimProject/XVim2.git # 下载完毕后,进入目录
cd xvim2 # 安装
make
  • 安装完成后显示\(BUILD\ SUCCEEDED\)则表示安装成功。

  • 打开\(Xcode\)提示Unexpected code bundle "XXVim2.xcpplugin,选择Load Bundle 即可。

自定义模版格式

  • 打开\(Finder\)。
  • 按快捷键:\(Command+Shift+G\)
  • 输入文件路径:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate
  • 复制文件\(TemplateInfo.plist\)到以下目录中:(没有文件夹的需要创建文件夹)
~/Library/Developer/Xcode/Templates/Application/My Command Line Tool.xctemplate
  • 修改\(TemplateInfo.plist\)文件:(根据需要自行修改第\(100\)行和最后一段)
<?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>languageChoice</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 &lt;stdio.h&gt;
</string>
<key>main.c:main:content</key>
<string>// insert code here...
printf(&quot;Hello, World!\n&quot;);
return 0;
</string>
</dict>
</dict>
<key>C++</key>
<dict>
<key>Nodes</key>
<array>
<string>main.cpp:include</string>
<string>main.cpp:main:content</string>
</array>
<key>Definitions</key>
<dict>
<key>main.cpp:include</key>
<string>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef int Int;
#define int long long
#define INF 0x3f3f3f3f
#define maxn 200000
int a[maxn];</string>
<key>main.cpp:main:content</key>
<string>ios::sync_with_stdio(false);
cin.tie(0);
return 0;
</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 &lt;Foundation/Foundation.h&gt;
</string>
<key>main.m:main:content</key>
<string>@autoreleasepool {
// insert code here...
NSLog(@&quot;Hello, World!&quot;);
}
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>
<key>Release</key>
<dict>
<key>SWIFT_COMPILATION_MODE</key>
<string>wholemodule</string>
<key>SWIFT_OPTIMIZATION_LEVEL</key>
<string>-O</string>
</dict>
</dict>
</dict>
<key>Targets</key>
<array>
<dict>
<key>SharedSettings</key>
<dict>
<key>SWIFT_VERSION</key>
<string>5.0</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(&quot;Hello, World!&quot;)
</string>
</dict>
</dict>
</dict>
</dict>
</array>
<key>Definitions</key>
<dict>
<key>*:main</key>
<dict>
<key>Beginning</key>
<string>signed main() {</string>
<key>End</key>
<string>}</string>
<key>Indent</key>
<integer>1</integer>
</dict>
</dict>
</dict>
</plist>

多文件编译

  • 正常创建工程即可,当需要创建第二个文件时选择\(File->New->Target\)。然后正常创建一个\(Console\)文件。编译运行的时候,在窗口左上角选择要运行的文件即可。

用Xcode配置完美ACMer环境的更多相关文章

  1. 2016年最新mac下vscode配置golang开发环境支持debug

    网上目前还找不到完整的mac下golang环境配置支持,本人配置成功,现在整理分享出来. mac最好装下xcode,好像有依赖关系安装Homebrew打开终端窗口, 粘贴脚本执行/usr/bin/ru ...

  2. 越狱开发:用iosOpenDev配置越狱开发环境 编写第一个hello world-b

    上网搜索越狱环境搭建,查到iosOpenDev软件,是个很方便的编写插件,而且可以直接用Xcode创建的工具,便开始着手学习如何去安装 集合了网上的方法后,我安装的时候发现: 1.作者最后更新的时间是 ...

  3. macOS Mojave配置OpenGL开发环境

    ---恢复内容开始--- 前言: 本文写作目的: 是由于本人参考 csdn原文 的方法配置环境时踩了很多坑,所以在此写一篇文防止以后用到. 工具: Xcode CMake 步骤: 准备工作: Xcod ...

  4. 安装与配置Flutter开发环境

    这篇博客我们介绍了Flutter,并且对比了H5,React Native,Flutter. 由于Flutter是跨平台的开发框架,开发一次可以同时运行在Android和iOS上面,所以我们开发时最好 ...

  5. Mac使用Xcode配置openGL

    Mac使用Xcode配置openGL 博主这学期有图形学课要用到OpenGL,于是首先就开始配置开发环境了.应该说网上Windows上配置OpenGL教程比较多,Mac版的比较少.博主特来分享配置过程 ...

  6. 【OS X系统】Xcode中搭建Python环境。

    虽然按照网上教程一步一步来,但还是遇到了几个错误点,现整理出来,主要是自己做个笔记,同时也希望能帮助到其他像我一样第一次在Xcode上搭建Python环境的人.首先感谢原作者:https://zhid ...

  7. 配置OpenCV+VS2013环境

    配置OpenCV+VS2013环境 准备工作 win7系统 下载opencv的windows编译版 安装vs2013 express 设定环境变量 按windows窗键输入path,选择第二个结果编辑 ...

  8. 在 IntelliJ IDEA 中配置 JSF 开发环境的入门详解

    JSF 作为 JavaEE 官方标准,在了解并掌握其基本开发技术后,对于功能要求较高.业务流程复杂的各种现代 Web 应用程序开发将会成为非常合适且强大的高效率开发利器.JSF 的开发环境搭建涉及到在 ...

  9. Mac上通过docker配置PHP开发环境

    这篇文章介绍的内容是关于Mac上通过docker配置PHP开发环境,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 更多PHP相关知识请关注我的专栏PHP​zhuanlan.zhihu. ...

随机推荐

  1. 看看该死的jquery.form.js的用法,不是个东西

    $("#btnReg").click(function () { var options = { //target: '#output', // 把服务器返回的内容放入id为out ...

  2. 软件测试成熟度模型TCMM (转载)

    下面我们就看看是如何划分的,来评判一下各位同仁自己所在的公司,所在的级别. TCMM Level 1:Initial(初始级)   测试处于一个混乱的状态,还不能把测试同调试分开,在编码完成后才进行测 ...

  3. Django:将后台返回的数据填充到select下拉框中

    select选择框如下: <select data-placeholder="选择项目..." class="form-control" name=&qu ...

  4. git rebase VS git merge

    git rebase VS git merge 写在前面 如果你不能很好的应用 Git,那么这里为你提供一个非常棒的 Git 在线练习工具 Git Online(回复公众号「工具」,获取更多内容) , ...

  5. canal启动报错ERROR c.a.o.canal.parse.inbound.mysql.dbsync.DirectLogFetcher - I/O error while reading from client socket

  6. Python31之类和对象1(三大特征:多封继——多疯子)

    一.对象: Python即是面向对象的编程也是面向过程的编程语言,其内部可谓是无处不对象,我们所熟知的列表,字符串等工厂函数本质上都是对象.对象其实是对属性和方法的封装. 属性是对象的静态特征 方法是 ...

  7. JqueryMobile与php跳转问题

    JqueryMobile提交表单到php时,会出现空白页面,需要手动刷新才会显示php页面. 修正方法:form元素中添加data-ajax=“false”. 具体原理:https://blog.cs ...

  8. Python基础 — 数据类型转换

    Python 数据类型转换 有时候,我们需要对数据内置的内心进行转换,数据类型的转换,你只需要将数据类型作为函数名即可. 以下几个内置的函数可以执行数据类型之间的转换,这些函数返回一个新的对象,表示转 ...

  9. mininet:使用vxlan连接两台虚拟机的网络topo

    需改虚拟机的网络适配器,将其改为host-only 尝试ping宿主机ip地址,此时能够ping同与虚拟机相连的虚拟网卡ip地址,无法ping同其他网卡ip地址 在虚拟机和宿主机中创建网络topo 在 ...

  10. Oracle随笔之用拆分后的列数据关联表查询

    -----------------------建表------------------------- create table test(id int, plist varchar2(30)) ; c ...