如何在 Xcode 5 中重命名项目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19442867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:58:30  来源:igfitidea点击:

How do I rename a project in Xcode 5?

xcodexcode5

提问by uchuugaka

How do I rename a project in Xcode 5? What steps do I need to take? In the past this was always a very tricky manual process.

如何在 Xcode 5 中重命名项目?我需要采取哪些步骤?在过去,这总是一个非常棘手的手动过程。

回答by uchuugaka

Well, the answer is very very very Apple simple in Xcode 5! In the Project Navigator on the left side, click 2 x slowly and the Project file name will be editable. Type the new name. A sheet will appear with a warning and will list all the items Xcode 5 believes it should change. You can probably trust it, but you should inspect it. The list will include the info.plist and various files, but also all the relevant strings from nib/xib files like MainMenu menus.

嗯,答案在 Xcode 5 中非常非常简单!在左侧的项目导航器中,缓慢单击 2 x,项目文件名将是可编辑的。键入新名称。将出现一个带有警告的工作表,并列出 Xcode 5 认为它应该更改的所有项目。您可能可以信任它,但您应该检查它。该列表将包括 info.plist 和各种文件,以及来自 nib/xib 文件(如 MainMenu 菜单)的所有相关字符串。

Accept the changes and you will get the prompt to save a snapshot of the project. Always make a snapshot when Xcode asks, it will be useful to restore if something does not work.

接受更改,您将收到保存项目快照的提示。当 Xcode 询问时总是制作一个快照,如果某些东西不起作用,恢复它会很有用。

回答by Priyanka Singh

Change the project name:-

更改项目名称:-

  1. Click on the target in xcode, on the right in "Identify and Type" under name change the name and press the ENTER button on your keyboard.
  2. A window will appear confirming the change and what it will change. Once you confirm it will make the changes.
  1. 在 xcode 中单击目标,在名称下的“识别和类型”右侧更改名称,然后按键盘上的 ENTER 按钮。
  2. 将出现一个窗口,确认更改及其将更改的内容。一旦您确认,它将进行更改。

Change the root folder name:-

更改根文件夹名称:-

  1. Go to the project directory and rename the root folder,
  2. Open the project and u will find all the file are missing, u need to add all the files of project again
  3. Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor. 4>Search and replace any occurrence of the original folder name with the new folder name. 5>Save the file.
  1. 转到项目目录并重命名根文件夹,
  2. 打开项目,你会发现所有的文件都丢失了,你需要重新添加项目的所有文件
  3. 右键单击项目包 .xcodeproj 文件,然后从上下文菜单中选择“显示包内容”。使用任何文本编辑器打开 .pbxproj 文件。4>搜索并用新文件夹名称替换任何出现的原始文件夹名称。5>保存文件。

Change the Scheme name:-

更改方案名称:-

  1. rename .xscheme file enter image description here
  1. 重命名 .xscheme 文件 在此处输入图片说明

If your Project is static framework then make sure your header file has public target membership

如果您的项目是静态框架,请确保您的头文件具有公共目标成员资格

回答by Moe

In Xcode 8.0, to rename your project, just go through the following instructions as described in Xcode help:

在 Xcode 8.0 中,要重命名您的项目,只需按照 Xcode 帮助中的说明执行以下说明:

1- Select your project in the project navigator.

2- In the Identity and Type section of the File inspector, enter a new name into the Name field.

3- Press Return.

A dialog is displayed, listing the items in your project that can be renamed. The dialog includes a preview of how the items will appear after the change.

4- To selectively rename items, disable the checkboxes for any items you don't want to rename. To rename only your app, leave the app selected and deselect all other items.

5- Click Rename.

1- 在项目导航器中选择您的项目。

2- 在文件检查器的身份和类型部分,在名称字段中输入一个新名称。

3- 按回车。

将显示一个对话框,列出项目中可以重命名的项目。该对话框包括更改后项目将如何显示的预览。

4- 要有选择地重命名项目,请禁用您不想重命名的任何项目的复选框。要仅重命名您的应用程序,请选择该应用程序并取消选择所有其他项目。

5- 单击重命名。

Source: http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f

来源:http: //help.apple.com/xcode/mac/8.0/#/dev3db3afe4f

回答by Ian Dundas

I really recommend just opening the folder in a general editor such as Sublime Text, and doing a find/replace across the whole folder. The other methods I found were unstable, particularly when combined with .xcworkspace and cocoapods.

我真的建议只在通用编辑器(例如 Sublime Text)中打开文件夹,然后在整个文件夹中进行查找/替换。我发现的其他方法不稳定,尤其是与 .xcworkspace 和 cocoapods 结合使用时。

回答by BadmintonCat

Xcode 6 (beta 6 as of now) seems to be not very reliable with renaming projects. For me it didn't rename several of the files and groups. It also doesn't rename the physical folder the project is in. To rename my project to be sure that everything is clean I went the extra length to create a new project with the new name and copy over all the files. The assets are easy to copy but groups have to be recreated. The biggest issue with this however are CoreData data model files. Trying to simply copy this will result in a corrupt model file, even though everything looks like it is alright.

Xcode 6(目前为 beta 6)在重命名项目时似乎不太可靠。对我来说,它没有重命名几个文件和组。它也不会重命名项目所在的物理文件夹。为了重命名我的项目以确保一切都是干净的,我花了额外的时间用新名称创建一个新项目并复制所有文件。资产易于复制,但必须重新创建组。然而,最大的问题是 CoreData 数据模型文件。尝试简单地复制它会导致模型文件损坏,即使一切看起来都很好。

回答by Julian Vogels

In Xcode 7, renaming a project can still break your app. Make sure you backed it up before trying it. Click on the project icon and find the project name in the inspector pane. If you change it there, Xcode will ask you if you want to rename related files. Might work. But if not, try this brute force approach:

在 Xcode 7 中,重命名项目仍然会破坏您的应用程序。确保在尝试之前备份它。单击项目图标并在检查器窗格中找到项目名称。如果您在那里更改它,Xcode 会询问您是否要重命名相关文件。可能工作。但如果没有,请尝试这种蛮力方法:

  1. Close Xcode
  2. Using an advanced text editor like Sublime Textor Atom, open the root folder. It will open the folder structure.
  3. Perform a Global Search and Replace (it's probably cmd + shift + f), and replace My Wrong App Namewith New App. If your project name contained spaces, also search for My_Wrong_App_Nameand replace with New_App. This changes all file contents.
  4. Now you need to find all the files inside the project with your old app name. Rename them all, also the folders.
  5. Important: Open the project file with right click > Show Package Contents, and rename all files in there.
  6. Reopen your Xcode project or workspace. Compile.
  1. 关闭 Xcode
  2. 使用像Sublime TextAtom这样的高级文本编辑器,打开根文件夹。它将打开文件夹结构。
  3. 执行全局搜索和替换(可能是cmd + shift + f),并替换My Wrong App NameNew App。如果您的项目名称包含空格,请搜索My_Wrong_App_Name并替换为 New_App. 这会更改所有文件内容。
  4. 现在,您需要使用旧应用程序名称查找项目中的所有文件。将它们全部重命名,还有文件夹。
  5. 重要提示:右键单击> 显示包内容打开项目文件,并重命名其中的所有文件。
  6. 重新打开您的 Xcode 项目或工作区。编译。

If you use Pods, you need to open the pods project as well and change the files in there.

如果您使用 Pods,则还需要打开 Pods 项目并更改其中的文件。

回答by msmq

When you re-name the project name in XCode5 then info.plist entry removed from Targets --- > General ---> identity. You just need to mention it again.

当您在 XCode5 中重命名项目名称时,从 Targets ---> General ---> identity 中删除了 info.plist 条目。你只需要再次提及它。

enter image description here

在此处输入图片说明

回答by malkoty

Hereis another great example which works well with xcode 5

是另一个很好的例子,它适用于 xcode 5