如何完全重命名 Xcode 项目(即包括文件夹)? [英] How do I completely rename an Xcode project (i.e. inclusive of folders)?

查看:33
本文介绍了如何完全重命名 Xcode 项目(即包括文件夹)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 XXX 的项目.我想将此项目重命名为 YYY.

I have a project named XXX. I want to rename this project to YYY.

请注意,XXX 是一个非常常见的术语(例如数据",或简称为项目"),因此简单的 RegEx 搜索和替换是不可能的,除了损坏项目配置文件的风险.

Note that XXX is an extremely common term (for e.g. "data", or simply "project"), and thus a simple RegEx search-and-replace is not possible, out of risk of corrupting the project configuration files.

我当前的项目目录包含以下项目:

My current project directory contains the following items:

  • XXX
  • XXXTests
  • XXX.xcodeproj

我想将它们重命名为:

  • YYY
  • YYYTests
  • YYY.xcodeproj

... 分别,必要的更改反映在我的项目文件中.

... respectively, with the necessary changes being reflected in my project file.

如何在无需手动创建和填充新项目的情况下完成此操作?

How can I accomplish this without having to manually create and populate a new project?

推荐答案

步骤 1 - 重命名项目

  1. 在项目导航器"中单击要重命名的项目;在 Xcode 窗口的左侧面板中.
  2. 在右侧面板中,选择文件检查器",您的项目名称应位于身份和类型"下.将其更改为您的新名称.
  3. 当对话框询问是否重命名项目的内容项,单击重命名".对任何有关未提交更改的警告说是".

第 2 步 - 重命名方案

  1. 在窗口顶部,停止"旁边按钮,您的产品在其旧名称下有一个方案;单击它,然后选择管理方案...".
  2. 点击方案中的旧名称,它将变得可编辑;更改名称并单击关闭".

第 3 步 - 用您的资产重命名文件夹

  1. 退出 Xcode.重命名包含所有项目文件的主文件夹.
  2. 在正确命名的主文件夹中,在您新命名的 .xcodeproj 文件旁边,可能有一个错误命名的 OLD 文件夹包含您的源文件.将 OLD 文件夹重命名为您的新名称(如果您使用 Git,您可以运行 git mv oldname newname 以便 Git 识别这是一个移动,而不是删除/添加新文件).
  3. 在 Xcode 中重新打开项目.如果您看到警告文件夹 OLD 不存在",请关闭警告.重命名文件夹中的源文件将具有红色名称,因为它们的路径已损坏.
  4. 在项目导航器"中在左侧面板中,单击代表您重命名的 OLD 文件夹的顶级文件夹.
  5. 在右侧面板的身份和类型"下,更改名称"字段从旧名称到新名称.
  6. 就在该字段下方是位置"菜单.如果完整路径没有自行更正,请单击附近的文件夹图标并选择重命名的文件夹.如果指向每个源文件的链接仍然断开,您可能必须对它们执行此修复.
  1. Quit Xcode. Rename the master folder that contains all your project files.
  2. In the correctly-named master folder, beside your newly-named .xcodeproj file, there is probably a wrongly-named OLD folder containing your source files. Rename the OLD folder to your new name (if you use Git, you could run git mv oldname newname so that Git recognizes this is a move, rather than deleting/adding new files).
  3. Re-open the project in Xcode. If you see a warning "The folder OLD does not exist", dismiss the warning. The source files in the renamed folder will have red names because the path to them has broken.
  4. In the "Project navigator" in the left-hand panel, click on the top-level folder representing the OLD folder you renamed.
  5. In the right-hand panel, under "Identity and Type", change the "Name" field from the OLD name to the new name.
  6. Just below that field is a "Location" menu. If the full path has not corrected itself, click on the nearby folder icon and choose the renamed folder. You may have to perform this fix for each source file if the links to them remain broken.

第 4 步 - 重命名构建 plist 数据

  1. 单击项目导航器"中的项目;在左侧,然后在主面板中选择构建设置".
  2. 搜索plist"在设置中.
  3. 在包装"部分,您将看到 Info.plistProduct Bundle Identifier 的字段.
  4. 如果在 Info.plist 中输入了文件名,请更新它(它可能已在步骤 1 中自动更新).
  5. Product Bundle Identifier 执行相同的操作,除非它使用 ${PRODUCT_NAME} 变量.在这种情况下,搜索产品"即可.在设置中更新Product Name.如果Product Name是基于${TARGET_NAME},点击设置面板左侧TARGETS列表中的实际目标项进行编辑,相关设置会立即更新.
  6. 搜索前缀"的设置并确保 Prefix Header 的路径也更新为新名称.
  7. 如果您使用 SwiftUI,请搜索Development Assets";并更新路径.
  1. Click on the project in the "Project navigator" on the left, and in the main panel select "Build Settings".
  2. Search for "plist" in the settings.
  3. In the Packaging section, you will see fields for Info.plist and Product Bundle Identifier.
  4. If there is a file name entered in Info.plist, update it (it may have been updated automatically in Step 1).
  5. Do the same for Product Bundle Identifier, unless it is utilizing the ${PRODUCT_NAME} variable. In that case, search for "product" in the settings and update Product Name. If Product Name is based on ${TARGET_NAME}, click on the actual target item in the TARGETS list on the left of the settings pane and edit it, and all related settings will update immediately.
  6. Search the settings for "prefix" and ensure that Prefix Header's path is also updated to the new name.
  7. If you use SwiftUI, search for "Development Assets" and update the path.

第 5 步 - 重复第 3 步进行测试(如果有)

第 6 步 - 如果核心数据的名称与项目名称匹配(如果有),则对核心数据重复第 3 步

第 7 步 - 清理并重建您的项目

  1. Command + Shift + K 清理
  2. Command + B 构建
  1. Command + Shift + K to clean
  2. Command + B to build

这篇关于如何完全重命名 Xcode 项目(即包括文件夹)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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