简体   繁体   English

如何在 Xcode 中更改工作区名称?

[英]How to change workspace name in Xcode?

Is there any appropriate way to change workspace name in Xcode?有什么合适的方法可以在 Xcode 中更改工作区名称吗?

Seems to me that it works to quit Xcode and manually change the .xcworkspace file from OLD_NAME.xcworkspace to NEW_NAME.xcworkspace .在我看来,它可以退出 Xcode 并手动将.xcworkspace文件从OLD_NAME.xcworkspace更改为NEW_NAME.xcworkspace

Xcode 5 was used at the time of writing.在撰写本文时使用的是 Xcode 5。

Steps to Rename Workspace重命名工作区的步骤

  1. Rename the Folder( contain all files) of Main Project重命名主项目的文件夹(包含所有文件)
  2. Rename the Workspace重命名工作区
  3. delete the Xcode project from Workspace and re-add/Drag Xcode project again to Workspace.从 Workspace 中删除 Xcode 项目,然后重新添加/将 Xcode 项目再次拖动到 Workspace。 And in build setting rename “product name”并在构建设置中重命名“产品名称”
  4. Now, In Workspace ,select the project in general , option for selecting infoPlist will appear, select the info plist of project.现在,在 Workspace 中,选择一般项目,将出现选择 infoPlist 的选项,选择项目的 info plist。 then, Click the Manage Scheme and Create New Scheme with Xcode Project Name , check the New Created Scheme and delete the older one.然后,单击 Manage Scheme 和 Create New Scheme with Xcode Project Name ,选中 New Created Scheme 并删除旧的。
  5. clear the both Xcode and Workspace ..and delete Derived Data “~/Library/Developer/Xcode”清除 Xcode 和 Workspace ..并删除派生数据“~/Library/Developer/Xcode”
  6. if project contain Bridging Header file then , just rename the Bridging Header file with With project name - “ProjectName-Bridging-Header.h” and then open the Xcode project not workspace.如果项目包含桥接头文件,那么只需使用项目名称 - “ProjectName-Bridging-Header.h”重命名桥接头文件,然后打开 Xcode 项目而不是工作区。 In build settings.. in “Swift Compiler -Code Generation”—> Objective-C Bridging Header — “reset the Path of Bridging header file”.在构建设置中..在“Swift Compiler -Code Generation”—> Objective-C Bridging Header—“重置桥接头文件的路径”。 close the Xocde.关闭 Xocde。 And if Project Contain Pod File , then open Pod file rename the target name with new project .close both xocde project and Workspace project and install the pod.如果 Project Contain Pod File ,则打开 Pod 文件,使用新项目重命名目标名称。关闭 xocde 项目和 Workspace 项目并安装 pod。
  7. now open the Workspace clean and build.现在打开工作区清理并构建。

2019: 2019年:

First note that this question is about changing the name of an Xcode workspace .首先请注意,这个问题是关于更改 Xcode工作区的名称。 The QA is not about changing the name of a project, a project within a workspace, the source folder, or other aspects of naming in the Xcode milieu. QA 与更改项目名称、工作区中的项目、源文件夹或 Xcode 环境中命名的其他方面无关。

Xcode 11 and further. Xcode 11 及更高版本。

Surprisingly, you can now just change the name of the file !令人惊讶的是,您现在可以更改文件名 As strange as that seems.看起来很奇怪。

  1. Quit Xcode.退出 Xcode。 You must do this first.你必须先这样做。

  2. Using your mouse, and keyboard, change the name:使用鼠标和键盘更改名称:

在此处输入图片说明

在此处输入图片说明

This causes no problem with Swift Package Manager or any other issue.这不会导致 Swift Package Manager 或任何其他问题。

You now simply open the .xcworkspace file as normal.您现在只需像往常一样打开 .xcworkspace 文件。

One part of a fifteen year old Apple problem resolved!一个十五年前的苹果问题的一部分解决了!

Yeah I reckon so.是的,我也这么认为。 As far as I can see, a workspace is just a reference to one or more Xcode projects and doesn't produce anything outside of those projects.据我所知,工作区只是对一个或多个 Xcode 项目的引用,不会在这些项目之外生成任何内容。

I tried the same (XC6) but got a build error with one file not found.我尝试了相同的 (XC6),但出现构建错误,找不到一个文件。 Not a huge issue, but for some it might not be worth the effort.不是一个大问题,但对某些人来说可能不值得付出努力。

In my case I had to rename also the project inside the workspace which had the same name.在我的情况下,我还必须重命名工作区中具有相同名称的项目。

For that it was important before renaming the project to..为此,在将项目重命名为..

  • close Xcode关闭 Xcode
  • rename the .xcworkspace -file from the Finder从 Finder 重命名.xcworkspace文件
  • open Xcode with new named workspace使用新命名的工作区打开 Xcode
  • rename the project inside the workspace with Xcode help by clicking on the project name通过单击项目名称,在 Xcode 帮助下重命名工作区中的项目

I want to change the workspace name, project name and all linked file with old project name, so I tried the steps from this post, and it's really helpful我想用旧的项目名称更改工作区名称、项目名称和所有链接文件,所以我尝试了这篇文章中的步骤,这真的很有帮助

Renaming an Xcode project with Pods: the easy way https://medium.com/programming-lite/renaming-an-xcode-9-project-with-pods-the-easy-way-5d1228ef25a使用 Pods 重命名 Xcode 项目:简单的方法https://medium.com/programming-lite/renaming-an-xcode-9-project-with-pods-the-easy-way-5d1228ef25a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM