是否可以对 Xcode 项目的 Build Phases 部分中的 Compile Sources 列表进行排序? [英] Is it possible to sort the Compile Sources list in the Build Phases section of an Xcode project?

查看:89
本文介绍了是否可以对 Xcode 项目的 Build Phases 部分中的 Compile Sources 列表进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据名称对我的 Xcode 项目的编译源"部分中的文件进行排序.可能吗?

I want to sort the files in the 'Compile Sources' section of my Xcode project according to their names. Is it possible?

推荐答案

是的,您可以在 Xcode 中重新排序 Compile Sources 部分,但不能从 GUI 重新排序 - 考虑到这是一种耻辱已经是 IDE 的第 6 版,但他们仍然没有使用这个基本功能.

Yes, you can reorder the Compile Sources section in Xcode, but not from the GUI - which is a shame considering that this is already version 6 of the IDE and they still haven't gotten around to this basic feature.

正如 A-Live 所说,您需要编辑 yourproject.xcodeproj 文件中的 project.pbxproj 文件.使用 Finder 选择 yourproject.xcodeproj 文件,然后使用上下文菜单显示包内容.之后,使用文本编辑器打开 project.pbxproj 文件.

As A-Live said, you need to edit the project.pbxproj file within the yourproject.xcodeproj file. Use Finder to select the yourproject.xcodeproj file and then use the context menu to Show Package Contents. After that open the project.pbxproj file with a text editor.

找到 PBXSourcesBuildPhase 部分并将 files = (); 之间的所有内容复制到一个新的文本文件中.删除前导标签/空格.将该文件保存在磁盘上的某个位置.打开终端并执行以下操作:

Find the PBXSourcesBuildPhase section and copy everything between files = ( and ); into a new text file. Remove the leading tabs/spaces. Save that file somewhere on your disk. Open up a terminal and do this:

 sort -bf -t " " -k 3 PBXSourcesBuildPhase.txt > PBXSourcesBuildPhase.sorted.txt

在文本编辑器中打开新的 PBXSourcesBuildPhase.sorted.txt 文件,将排序后的行复制到 project.pbxprojPBXSourcesBuildPhase 部分(覆盖您之前复制)并保存.

Open up the new PBXSourcesBuildPhase.sorted.txt file in your text editor, copy the sorted lines into the PBXSourcesBuildPhase section of your project.pbxproj (overwrite the lines that you previously copied) and save.

现在您应该能够看到在 Xcode 中的 Compile Sources 部分中排序的所有文件.

Now you should be able to see all the files sorted in the Compile Sources section in Xcode.

我已经在 Xcode 6.0.1 中用一个小项目(约 150 个源文件)对此进行了测试,没有出现任何问题.

I've tested this in Xcode 6.0.1 with a small project (~150 source files) and had no problems.

小心:在尝试之前,您应该备份您的项目文件(或者更好:使用版本控制).以防万一.

Careful: you should make a backup of your project file (or better: use version control) before you try this. Just in case.

这篇关于是否可以对 Xcode 项目的 Build Phases 部分中的 Compile Sources 列表进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆