Changing the name of main folder in Xcode project - xcode

This is not the first time I've had trouble with this and I suspect not the last time either. Despite having learned many frameworks inside out I still find the organizational structure of a simple xcode project elusive. I simply wanted to retitle a project from CATouchSynth to ABTouchSynth. A while ago I discovered that if you click on the Project folder in project navigator and than change the name in the Identity and Type section it will rename many of the relevant files and directories to the new name. However, there is one main folder inside the folder on your computer that doesn't change and still has the old name. I could see no way to change this folder name through Xcode and so I renamed it manually from finder. This turned all of my source files and assets red so I manually "relinked" them in xcode and they are now non-red and seemingly linked with the newly named folder. However I am getting several compile-time errors talking about the old folder name but I have no clue what Xcode is referring too. The errors look like this
It seemed as if derived data was an issue so I deleted the derived data folder from Xcode and I still get these errors. Has anyone experienced this before and what can I do to ressurrect my project?

Note: Before doing any changes do backup your project folder. This is seriously recommended.
Follow the steps below to rename the source folder of your project –
Close XCode.
Rename the Source Folder.
Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor (Xcode).
This step should be done with extreme caution. Search and replace any occurrence of the original folder name with the new folder name.
Save and Close the file.
Open XCode project.

The error is happening at build time during the compile phase, so you will have to go into the app target's Compile Sources build phase, remove all those .m files, and add them again.

Related

Couldn't load a Xcode project with pods [duplicate]

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.
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.
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.
Change the project name:-
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.
A window will appear confirming the change and what it will change. Once you confirm it will make the changes.
Change the root folder name:-
Go to the project directory and rename the root folder,
Open the project and u will find all the file are missing, u need to add all the files of project again
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.
Change the Scheme name:-
rename .xscheme file
If your Project is static framework then make sure your header file has public target membership
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.
In Xcode 8.0, to rename your project, just go through the following instructions as described in Xcode help:
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.
Source: http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f
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.
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.
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:
Close Xcode
Using an advanced text editor like Sublime Text or Atom, open the
root folder. It will open the folder structure.
Perform a Global Search and Replace (it's probably cmd + shift + f), and
replace My Wrong App Name with New App. If your project name contained spaces, also search for My_Wrong_App_Name and replace
with
New_App. This changes all file contents.
Now you need to find all
the files inside the project with your old app name. Rename them
all, also the folders.
Important: Open the project file with
right click > Show Package Contents, and rename all files in there.
Reopen your Xcode project or workspace. Compile.
If you use Pods, you need to open the pods project as well and change the files in there.
Here is another great example which works well with xcode 5

Rename Xcode Project Doesn't Change Filesystem Project Folder Name - Not A Redo of Other Q's

Using Xcode 4.5.2
I occasionally want to rename a project all the way through the project without leaving obvious folder name atavisms from previous versions in the project 's file system.
The usual instructions for renaming an Xcode project do not accomplish this. I have read them and done them many times. They only go so far. They leave the main directory (at the same level as the .xcode.proj file) with the ORIGINAL project name. Call me persnickety but I don't like that. So I endeavor to change it as follows.
I begin with the usual instructions, then attempt to rename the remaining original folder name both in Xcode and in Finder. It ends badly. Here are the steps I follow. It should be reproducible.
We will attempt to change a project named "JoeSchmoe" to "JoeSchmoe_1".
Do the Usual Project Rename Procedure
Create a new Xcode Utility project, named: "JoeSchmoe". Use Storyboards and ARC.
Build, run, and test functionality to verify that everything is OK. It is. Stop.
Hit cmd-shift-J
Open the Utilities panel on the right
Under Identity, change project name to "JoeSchmoe_1". Xcode will ask you, "Rename content project items?" Click "Rename"
Build. It should succeed. And it does.
The Problem
In the Project Navigator, notice that the main folder in the project is still named "JoeSchmoe"!
Change the name of that folder to JoeSchmoe_1
Build. It should succeed. And it does. We're done, right? Well let's look at the project's file system.
Quit Xcode
In Finder, open the folder containing the newly renamed and working "JoeSchmoe_1.xcode.proj"
(Its containing folder is still named "JoeSchmoe". That's ok for now. We could change it to anything without affecting Xcode, so long as it contains the .xcode.proj file and associated files and directories. We leave it alone.)
In that directory (at the same level as the JoeSchmoe_1.xcode.proj file), notice that the main project folder is also still named "JoeSchmoe" !!
Change the name of this "JoeSchmoe" folder to "JoeSchmoe_1". (We expect this to break the project because we know Xcode will still be looking for the "JoeSchmoe" folder, since it didn't change it for us.)
Start Xcode
Build. It fails, as expected.
Notice that all the filenames in the Project Navigator are now red colored, meaning files not found. (We expected this. Now we want to fix it.)
In the Project Navigator, select the project (top icon), then Target -> Build Settings -> Packaging -> Info.plist File.
Notice the file pathname in the Info.plist File settings row is named: JoeSchmoe/JoeSchmoe_1-Info.plist !! The directory still has the old project name. But in the file system we just changed it. So let's make this the same as what's in the filesystem.
Change its name to JoeSchmoe_1/JoeSchmoe_1-Info.plist
Re-Verify that the directoryname/filenames are identical in the file system and what you have in your Xcode Packaging -> Info.plist setting.
If they are, the project should build. Right?
It Fails. And all of the project files are in red (meaning not found).
Try cleaning the project (Product menu -> Clean),
Quit Xcode, Restart and Build.
It Fails, as before.
At this point I don't have a theory as to why it fails, other than to assume that there is an Xcode setting that needs to be changed somewhere that I haven't yet discovered. Looked all around for it. I'm stumped.
What am I missing?
Since they got rid of the feature that was in Xcode 3 to easily change your project name, it's been a pain in the butt to do manually. I found a great app in the mac strore Project Duplicator for Xcode 4 that copies your project and lets you name it whatever you want. I've been using it for a while now and have never had an issue with it, and it was only $1 when I purchased it.
GW
The last thing I had to change when renaming a project, including the finder folders, is the setting under "Build Settings->Prefix Header". It was still pointing to a finder folder that no longer existed and the compiler would throw on a file not found error.
Once I changed this to my new inner project folder, it all worked fine and I've been able to build the project as expected.
See this answer for fixing the problem manually
Renaming xcode 4 project and the actual folder

The file <myproject>.xcodeproj doesn't exist

I have a folder with my working xcode project in it. However when I go to copy and paste the entire folder to a different location and then go to open the .xcodeproj file inside, I get an error saying the project doesn't exist!
Does anyone know why it's doing this and how I can open the project?
I experienced the same problem with an iOS project I checked out from a repository. The .xcodeproj file is a package that contains several files. You can view the contents by right-clicking on your .xcodeproj file and selecting "Show Package Contents". Inside the package, it's my understanding that you'll need several types of files to be present.
project.pbxproj contains all the references to files in your project, as well as many of the project settings. If your .xcodeproj package doesn't contain this, you're up a creek without a paddle.
When I first checked out my project, only this file was present and I was experiencing the same problem. I then copied and pasted two files, [login].pbxuser and [login].mode1v3, from the .xcodeproj file of another project. These files didn't appear to contain any settings specific to this project, and it helped get my project up and running. I know I'm a little late to answer your question, but I found it while searching for an answer myself.

Why can't I delete files from my XCode project?

This is probably a very easy question, but I'm having trouble deleting resources from my XCode project. I added them using "Create Folder References for any added folders" so that I could import a whole offline HTML site with its correct folder structure.
Unfortunately, now it has been added like this I don't seem to be able to delete individual files in the structure (it's not available from the Edit menu).
Can anyone help please? Thanks!
That isn't how folder references work. The idea is that its only a reference, you can open files within it and save it from those editors, you can delete or move the entire reference throughout the xcode project, but you can't actually edit it - its read only as far as xcode is concerned. Likewise, you cannot restructure it (move internal files around).
I'm not to sure why apple decided to make this the case, but apparently they have.
If you want to know how one might use the xcode folder system, here's how I tend to use them with my projects:
Whenever I subdivide code into folders, when I drag them into my project I click "recursively create groups for any added folders". If you do this, you any changes you make within xcode will not reflect the actual file itself. As far as I know, there is no way to do this. What does happen then is that when you add a new code file to it, the directory starts off in that file by default. ie, you don't need to navigate to it manually when you create a new file.
I use folder references whenever I'm working with content for an application I'm using. This way, I add all my images, folders, configuration files, whatever - and xcode immediately lists them. The reason I have it within xcode, I can I copy the files into the executables directory by dragging the folder reference into a "Copy Files" build phase.
Thats basically (to my knowledge) how one uses the folder types within xcode - sadly, I don't know how to achieve the functionality you want. You may have to manually delete the folders in finder, which if you do use folder references will update xcode to the change.
I ran into the same issue by using "Create Folder References for any added folders". I wanted to change some of the times but that's not possible. I had added a main folder that had other directories under it. I just had to select the main directory and deleted it and then just add the subdirectories that I needed. You can't make any location or removal changes to the directories that are added this way. -- Jeff
In the project browser, where you're looking at files, right click and choose "Delete". It'll prompt you to either remove the file from the project (leaving the underlying file on the filesystem) or to also move the underlying file to the trash.
I ran into the same issue. Delete the files from the folder directly as opposed to from within Xcode. You'll see the entries turn red under your project. Restarting Xcode should make these red entries vanish.

.xcodeproj doesn't open in Xcode

Until this evening everything was fine. But now Xcode doesn't open .xcodeproj files.
When I start Xcode then click File->Open and then click on .xcodeproj file, the open dialog is showing me .xcodeproj file's contents instead of opening the project. I found on the web that it may be due to an old version of Xcode but I am using 3.2.4.
What format is the volume on which the projects reside ? An Xcode project is actually a bundle, that is a directory containing a project.pbxproj file (this is the only important file) and some user-specific settings files (which are not important). Make sure the project.pbxproj file is present and has appropriate permissions. Also if this is a non HFS+ volumes then that may be part of the problem.
I got same error in my project finally i founded my answer. there total two option for solve this issue.
There is need one backup of your project. you can replace your .xcodeproj with old file.
you have to create new project and than have to add All old project file in new project.

Resources