336

I must be missing something obvious, but I can't figure out how to rename my project in Xcode 4.

If I remember correctly Xcode 3 had a dedicated menu item for this but there's no such entry in Xcode 4.

bneely
  • 9,083
  • 4
  • 38
  • 46
Ori
  • 12,800
  • 4
  • 33
  • 32

11 Answers11

612

Well, it turned out to be a trivial matter indeed.

All you need to do is click twice slowly on the project root in the project navigator and it then becomes editable. After you rename the project and press 'enter' it will suggest to automatically change all project-name-related entries and will allow you to de-select some of them if you want.

Nice.

Ori
  • 12,800
  • 4
  • 33
  • 32
  • 51
    Or just select it and hit enter. – Damien Jul 21 '11 at 14:51
  • 6
    Nice. Although, surely it couldn't have hurt to leave the menu item in too! – DonnaLea Aug 08 '11 at 02:21
  • 1
    This works great, but I also had to create a new scheme and delete the old one. The old scheme was still trying to target the old app name. – Jim Rhoades Nov 02 '11 at 21:20
  • 20
    **Or click once and hit Return** — same as renaming files in the Finder. :) – a paid nerd Dec 02 '11 at 20:47
  • @Jawboxer: It doesn't change the target; it's just the name of the scheme to use when compiling to different modes and devices. It's the name to save the configuration of checkboxes to, sort of like saving sets of compiler commandline parameters, as I understand it. – Henrik Erlandsson Jan 20 '12 at 08:50
  • This worked great for me, with a couple slight alterations. First, I selected the project root to highlight it, then clicked only once on the name of the project to make it editable. After confirming that I wanted to change the name of the project, and Xcode went about it's business changing the necessary files, I had to auto-create a new scheme and use that scheme to build. Thanks for your answer! – Mark Mckelvie Feb 09 '12 at 20:21
  • I M GETTING "The request could not be performed because it was returned by Subversion as invalid." error when renaming the stuff – Nik Feb 20 '12 at 17:09
  • 1
    Oh my objetive-god, this has been the best finding of all my findings in stackoverflow. I'm feeling like a complete idiot after two hours trying everything but the most obvious, most easy and most intuitive method for anybody but me that think I'm smarter than the average because I can write code. And for sure I'm not. – Gabriel Mar 10 '12 at 11:18
  • 1
    After renaming a project under Git, I can't commit anymore because XCode is looking for the git repository with the old project name in the path. How could I fix this ? – Patrick Marty Mar 12 '12 at 07:46
  • @Gabriel: don't feel too bad, I kinda felt the same way when I figured out this one :) – Ori Mar 14 '12 at 14:13
  • 1
    I agree with @DonnaLea. I don't know why they had to mess with stuff that works. – gonzobrains Mar 15 '12 at 23:19
  • Don't forget to update .gitignore if you're using it to ignore parts of the .xcodeproj directory as it will still refer to the old name – Martin Lockett May 29 '12 at 08:58
  • After renaming, svn couldn't add the new projectName.xcodeproj since it said it was already under version control. Solution: delete all the old .svn hidden directories under projectName.xcodeproj and then add to svn. – rimsky Jun 20 '12 at 21:22
  • Only problem is: XCode leaves back files in i.e. Supported files etc. with the old name. – esbenr Nov 27 '12 at 11:26
  • I still had to rename directories and groups to do that I had to click on the Group, "Show File in Inspector" then I had to edit the Identities Location. – Muskie Feb 03 '13 at 21:09
  • It's called a "doooouuble cliiiiick" – Ates Goral Feb 08 '15 at 15:57
82

Another option - Move the cursor on project name. Hit Enter. The project name becomes editable.

Vaishnavi Naidu
  • 2,625
  • 3
  • 25
  • 26
53

In addition to renaming the project, you may want rename the scheme so that it matches your new project name.

Xcode scheme name

To change the name of your scheme:

Product ==> Manage Schemes...

Then select your scheme and hit return/enter to edit the name.

Alternatively, Product ==> New Scheme... to create a new one with your new name :)

Community
  • 1
  • 1
RyanM
  • 4,474
  • 4
  • 37
  • 44
26

From Apple: iOS Developer Library Technical Q&A QA1625

Follow these steps to rename your application in Xcode 4.0 or later:

  1. In Xcode, select your target under "Targets" in the project editor, then choose View > Utilities > Show File Inspector.
  2. Xcode opens the file inspector pane. Enter your application's new name in the Project Name field as shown in Figure 1, then hit the return key on your keyboard.
  3. Xcode displays a project-rename dialog that contains all the items that can be renamed in your project. Leave your application selected in the dialog and deselect all other items as shown in Figure 2, then click Rename to perform the rename operation.

Figure 1 Figure 2

Community
  • 1
  • 1
rog
  • 5,351
  • 5
  • 33
  • 40
13

There is one other way.

To rename a project in Xcode 4, select the project file from the project navigator on the left side of the project window. Choose View > Utilities > File Inspector to open the file inspector on the right side of the project window. At the top of the file inspector is the Project Name text field. Enter a new project name and press the Return key or the Tab key.

A sheet opens asking if you want to rename the project content items. Click the Rename button to finish renaming the project.

Christian Loncle
  • 1,584
  • 3
  • 20
  • 30
  • I simply could not get the "click twice slowly" method to work for me today (even though it has in the past), but this one did. Great backup. – Mike Nov 26 '12 at 17:12
10

In addtion to the other answers provided if you would also like to rename the folder in which your files are placed by default (that exists at the same level as your *.xcodeproj file) then perform the below steps:

- In Finder copy and paste the '<RootFolder>/<OldProjectName>' folder 
      (in the same location) and 
      rename the copied folder to '<RootFolder>/<NewProjectName>'

- In XCode in the 'Project Navigator' (first tab in the pane on the left) 

foreach ('Group' you have in your project)
{
   Select the 'Group' and observe the details in the 'File Inspector' 
          (first tab in the pane on the right)

   if ('Path' == 'Relative to Group' 
          AND 'Full Path' ==  '<RootFolder>/<OldProjectName>')
   {
           Click the icon to change the path of the 'Group' 
           Choose the '<RootFolder>/<NewProjectName> folder
   }
}

- Delete the '<RootFolder>/<OldProjectName>' folder

- Open the Project Settings, choose the Project target and under 'Build Settings' 

  - find change the path appropriately for the following values:

        'Prefix Header' and 'Info.plist file' 

And you're done.

If you also have a Tests folder then you will want to repeat the same.

Oliver Pearmain
  • 19,885
  • 13
  • 86
  • 90
  • Huge thanks for this! I also had to fix added resources missing but that is easy enough: just drag the new files located at the new folder to the project group where the references are broken (in red). And I also had other broken references. Searching for in the 'Build Settings' was helpful to fix them. – cprcrack Sep 06 '13 at 17:15
2

EDIT 10/10/19: There is an awesome tool to rename projects in Xcode, I tried it and it works great:

https://github.com/appculture/xcode-project-renamer


I'm posting this since I have always been struggling when renaming a project in XCode.

Renaming the project is good and simple but this doesn't rename the source folder. Here is a step by step of what I have done that worked great in Xcode 4 and 5 thanks to the links below.

REF links:
Rename Project.
Rename Source Folder and other files.

1- Backup your project. If you are using git, commit any changes, make a copy of the entire project folder and backup in time machine before making any changes.

2- Open your project.

3- Slow double click or hit enter on the Project name (blue top icon) and rename it to whatever you like.

NOTE: After you rename the project and press ‘enter’ it will suggest to automatically change all project-name-related entries and will allow you to de-select some of them if you want. Select all of them and click ok.

4- Rename the Scheme a)Click the menu right next to the stop button and select Manage Schemes. b)Single-slow-click or hit enter on the old name scheme and rename it to whatever you like. c)Click ok.

5 - Build and run to make sure it works.

NOTES: At this point all of the important project files should be renamed except the comments in the classes created when the project was created nor the source folder. Next we will rename the folder in the file system.

6- Close the project.

7- Rename the main and the source folder.

8- Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor.

9-Search and replace any occurrence of the original folder name with the new folder name.

10- Save the file.

11- Open XCode project, test it.

12- Done.

fs_tigre
  • 10,650
  • 13
  • 73
  • 146
2

Open Navigator with shift command j. Its not the strip on the left, its on the right.

dbomberg
  • 21
  • 1
1

Renaming the project is really the best way to go.

Here's what I do In Xcode 4.3.2:

  • Duplicate original project in finder
  • Open the project file in the new folder.
  • Select project (little blue icon)
  • Click again and enter new project name. This makes reasonable choices like changing the target, changing the project filename and all appropriate references.

I make custom accessories with a bunch similar backend frameworks and icons. Nothing is perfect but this is a fast way to save a bunch of configuration clicks when apps have a lot of similarities.

1

None of these worked for me. The reason was that in Finder I had already manually changed oldAppName.xcodeproj to

newAppName.xcodeproj 

with the new name, so when I tried to edit the Project Name in Xcode 4, I got an error that it couldn't save newAppName.xcodeproj since it already existed. The solution was to change, using Finder, newAppName.xcodeproj to

anyOtherName.xcodeproj, 

and then I was able to edit the project name in Xcode and Xcode renamed the anyOtherName.xcodeproj to newAppName.xcodeproj.

James Testa
  • 2,901
  • 4
  • 42
  • 60
1

I encounter this problem too. What I do is that I just change the name of TARGETS. Then the name displayed on iPhone or simulator changes. The names of files in project don't change. Just try this way.

Frank Liu
  • 19
  • 1