设置Xcode项目以在自定义目录中添加新文件 [英] Settingup Xcode project to add new file in custom directory

查看:445
本文介绍了设置Xcode项目以在自定义目录中添加新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何设置Xcode项目,以便在Classes目录中创建新的类文件(.h/.m),在Interfaces目录中创建新的接口文件(.xib/.nib)?

How can i setup my Xcode project so that it creates new class files (.h/.m) in Classes directory and new interface files (.xib/.nib) in Interfaces directory?

默认情况下,Xcode在根项目目录中添加新文件,而我必须手动将它们放到Classs and Interfaces目录中.

By default Xcode adds new files in the root project directory, and i have to manually put these into Classes and Interfaces directories.

我指的是Xcode File> New File ...选项.我希望从Xcode项目创建的新文件自动移动到相应的目录,例如.h/.m文件是在Classes目录中自动创建的,.xib是在Interfaces目录等中自动创建的.我的意思是物理目录,而不是Xcode"Groups".

I'm referring to the Xcode File > New File... option. I want the new files created from the Xcode project to move automatically to corresponding directories e.g. .h/.m files get automatically created in Classes directory, and .xib get automatically created in Interfaces directory etc. And i mean physical directories, not Xcode "Groups".

推荐答案

我假设您已经在Xcode项目中创建了一个名为Classes的组(文件夹),或者类似的内容.选择它并执行Command + I(或右键单击它并选择获取信息").将路径"选项更改为要创建文件的位置.

I assume you've made a group (folder) called Classes, or something along these lines, inside your Xcode project. Select it and do Command+I (or right-click it and select Get Info). Change the "Path" option to the place where you want files to be created.

请注意,它只会影响您在其上创建的文件.在其他位置创建它们然后将其移至该组将不会将其移至目录.

Please note that it will only affect files you create on it. Creating them elsewhere then moving them to this group will not move them into the directory.

编辑上面的答案适用于Xcode3.在Xcode 5中,您需要在Project Navigator中选择逻辑组(第一个导航器选项卡,并用⌘1),然后使用文件检查器对其进行检查(第一个实用工具选项卡,并使用⌥⌘1进行显示).通过单击位置"下拉菜单下方的文件夹图标,可以更改所有新文件的默认物理文件夹.

EDIT The above answer applies to Xcode 3. In Xcode 5, you would need to select the logical group in the Project Navigator (first navigator tab, bring it up with ⌘1) and then inspect it with the File Inspector (first utility tab, bring it up with ⌥⌘1). The default physical folder for all the new files can be changed by clicking the folder icon below the Location dropdown menu.

这篇关于设置Xcode项目以在自定义目录中添加新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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