How do I rename a project in Xcode 5? - xcode

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

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

How can I change the location of files in xcode project?

I put some files on the same level of *.xcodeproj file carelessly. When I move these files into the right location in Finder, Xcode tells me that these files are missing. So I delete the group which contains these files whose names have been read (I realize it is a mistake). And I drag these files from Finder into the xcode to build a new group. But when I try to run the project, Xcode still can't find these code. How can I solve the problem?
When you see a file that is red (or in the wrong place), you can easily correct the location of these files by using the file inspector (which appears along the right side panel of your Xcode window).
It looks like this:
Clicking on the Folder icon next to the name will bring up an open panel from which you can choose the correct location of the file.
There is an easier way to re-organize files through the Xcode project. You can use Synx, it automatically fixes file paths, through the Xcode project groups.
You can check Github page for Synx
Synx
After intalling Synx just run the command below
synx path/to/my/project.xcodeproj
I found the answer.
3 things
1
removed the reference to the red files
then dragged them back into the project
relinked all my .m and .h files just incase
2
then removed the .app reference and dragged it back in to the project.
3
removed any duplicates or red files in the build phases
Fixed
Thanks everyone for your suggestions and help
From my point of view i would definitely avoid the virtual folders in the Xcode.The disadventage of this approach is whe nthe project gets bigger and bigger you can not find corresponding files in your filesystem easy.Even you click on "Show in finder" you need to look for the file among tens of files.
My approach is creating the folder in the finder and then dragging it to project.when i need to create a new file in this subfolder is will be added there anyhow.
Drag the new files from the finder to the Xcode project file structure.
Remove the old files.
I had a lot of class and find a good solution for solve this problem :)
1- Select a file that you want to change the location (Red)
2- Select "show the file inspector" from right side in Xcode
3- Select wrong path or unexpected path and copy like this screenshot
4- Close your project
5- Go to your root project and right click on "project *.xcodeproj" and select "Show package contents"
6- Right click on "project.pbxproj" and open with TextEdit
7- In the file select "Find and replace" or click on " Option+Command+F " and find location that you copied and replace with "" empty
8- Save and open the Xcode :)

Duplicate and rename Xcode project & associated folders [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I would like to be able to duplicate an entire Xcode project, rename the project and the associated files without Xcode going mental, and without having to manually re-import all files to the project.
This answer is the culmination of various other StackOverflow posts and tutorials around the internet brought into one place for my future reference, and to help anyone else who may be facing the same issue. All credit is given for other answers at the end.
Duplicating an Xcode Project
In the Finder, duplicate the project folder to the desired location of your new project. Do not rename the .xcodeproj file name or any associated folders at this stage.
In Xcode, rename the project. Select your project from the navigator pane (left pane). In the Utilities pane (right pane) rename your project, Accept the changes Xcode proposes.
In Xcode, rename the schemes in "Manage Schemes", also rename any targets you may have.
If you're not using the default Bundle Identifier which contains the current PRODUCT_NAME at the end (so will update automatically), then change your Bundle Identifier to the new one you will be using for your duplicated project.
Renaming the source folder
So after following the above steps you should have a duplicated and renamed Xcode project that should build and compile successfully, however your source code folder will still be named as it was in the original project. This doesn't cause any compiler issues, but it's not the clearest file structure for people to navigate in SCM, etc. To rename this folder without breaking all your file links, follow these steps:
In the Finder, rename the source folder. This will break your project, because Xcode won't automatically detect the changes. All of your Xcode file listings will lose their links with the actual files, so will all turn red. Note: You may have to do Step 2 first, then come back to this step.
In Xcode, click on the virtual folder which you renamed (this will likely be right at the top, just under your actual .xcodeproject) Rename this to match the name in the Finder, this won't fix anything and strictly isn't a required step but it's nice to have the file names matching.
In Xcode, Select the folder you just renamed in the navigation pane. Then in the Utilities pane (far right) click the icon that looks like dark grey folder, just underneath the 'Location' drop down menu. From here, navigate to your renamed folder in the finder and click 'Choose'. This will automagically re-associate all your files, and they should no longer appear red within the Xcode navigation pane.
In your project / targets build settings, search for the old folder name and manually rename any occurrences you find. Normally there is one for the prefix.pch and one for the Info.plist, but there may be more.
If you are using any third party libraries (Testflight/Hockeyapp/etc) you will also need to search for 'Library Search Paths' and rename any occurrences of the old file name here too.
Repeat this process for any unit test source code folders your project may contain, the process is identical.
This should allow you to duplicate & rename an Xcode project and all associated files without having to manually edit any Xcode files, and risk messing things up.
Credits
Many thanks is given to Nick Lockwood, and Pauly Glott for providing the separate answers to this problem.
Duplicating an Xcode 4 Project
Renaming xcode 4 project and the actual folder
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 (this step is not required but I highly recommended).
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.
EDIT 10/11/19:
There is a tool to rename projects in Xcode I haven't tried it enough to comment on it.
https://github.com/appculture/xcode-project-renamer
As of XCode 7 this has become much easier.
Apple has documented the process on their site:
https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/RenamingaProject/RenamingaProject.html
Update: XCode 8 link:
http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f
I am using this script after I rename my iOS Project. It helps to change the directories name and make the names in sync.
http://github.com/ytbryan/rename
NOTE: you will need to manually change the scheme's name.
I'm using simple BASH script for renaming.
Usage: ./rename.sh oldName newName
#!/bin/sh
OLDNAME=$1
NEWNAME=$2
export LC_CTYPE=C
export LANG=C
find . -type f ! -path ".*/.*" -exec sed -i '' -e "s/${OLDNAME}/${NEWNAME}/g" {} +
mv "${OLDNAME}.xcodeproj" "${NEWNAME}.xcodeproj"
mv "${OLDNAME}" "${NEWNAME}"
Notes:
This script will ignore all files like .git and .DS_Store
Will not work if old name/new name contains spaces
May not work if you use pods (not tested)
Scheme name will not be changed (anyway project runs and compiles normally)
In the example code for the book "Instant OpenCV for iOS" I have found a bash script that copies a project from a folder to another.
Doing a little research I've found a blog post from what seems to be the original author of the script: http://mohrt.blogspot.it/2009/01/renaming-xcode-project-from-command.html, where you can download the script. I gave it a try and running it from terminal like this
sh renameXcodeProject.sh <name-of-existing-folder> <name-of-folder-to-create>
works fine.
Additional info can be found opening the file with a text editor. Hope that helps
I using Xcode 6+ and I just do:
Copy all files in project folders to new Folders (with new name).
Open *.xcodeproj or *.xcworkspace
Change name of Project.
Click on schema and delete current chema and add new one.
Here is done, but name of window Xcode and *.xcodeproj or *.xcworkspace still <old-name>. Then I do:
pop install
Open <new name>.xcworkspace
One more thing to try!
When I copied all of my files, opened the project, and renamed it, everything changed to my new project name except for the test target! I got a linker error that said I was missing a file called "myOldProjectname.app". Here's what fixed it:
Click on your project settings and select your test target
Click on build settings and search for "test host"
Check those 2 file paths. Chances are that those 2 paths are still pointing at your old project name.
Hope that helps!
For anybody else having issues with storyboard crashes after copying your project, head over to Main.storyboard under Identity Inspector.
Next, check that your current module is the correct renamed module and not the old one.

How do you move an Xcode 4.2 project file to another folder?

Not crazy about the way Xcode 4.2 has laid out the files on disk. It creates a project file, then a single subfolder next to it that has all the code. We want the project file to be in that same folder, then the workspace file (if any) to be the folder's sibling. Makes for more portable layouts.
However, I can't STAND the lack of Save-as in Lion, and now, apparently Xcode 4.2 as well. At least with TextEdit I just grabbed the version from SL and it works. No such luck with Xcode as as you know, it's a completely different animal than Xcode 3.x.
So... how does one move/rename the project file relative to the source code?
Here is how you do it (I'm using in Xcode 4.3):
First, move your project file
1. Start out by closing the Xcode project
1. Move ProjectName.xcodeproj into the folder with all your code
1. Open the XCode project by clicking ProjectName.xcodeproj
Second, re-map your files
1. You do not need to remap the files one by one, you only need to map the groups
1. Open the "File Inspector" with ⌥⌘1 or View->Utilities->Show File Inspector
1. Click each group, then click the square icon (see screenshot below) and choose the folder your project file is in.
Icon to click:
"None" will show up when you choose the same folder your .xcodeproj file is in.
Conclusion:
I have a large project which contains ~650 files, but only 12 groups, so it takes just a few minutes to re-map everything.
Note:
Sometimes when mapping the files it doesn't recognize a folder change if the name is the same (ie. two folders with the same name). You may have to pick any other folder temporarily, then choose the actual project folder and the None indicator will appear.

Renaming xcode 4 project and the actual folder

I know how to rename the project in Xcode 4, but how do you rename the source folder? The thing is that renaming the project in Xcode, does only rename within Xcode (Though it is progress compared to previous) - but why Xcode is not renaming the folder in the filesystem I don't know.
You can do this from within Xcode without resorting to hand editing the pbxproj file in a text editor!
Here's how:
Rename your source folder in the Finder. This will break the project initially because Xcode doesn't automatically detect when the real folders that the virtual (yellow) project folders point to are changed, so all the files inside that folder will turn red in Xcode. Don't worry about that, we'll fix it in step 3.
In Xcode, click on the (now broken) virtual folder in the left-hand sidebar and rename it to match the name in the Finder (you can actually call it anything you want, or not rename it at all, but that would be insane). That won't fix the red files inside the folder, but that's OK.
In the right-hand sidebar in Xcode, click the icon shown in the screenshot below to bring up a file dialog. Select the folder that you previously renamed. This will re-associate the virtual folder with the real folder on disk, and will automatically fix the links to all the files inside.
In your build settings, search for the old folder name and manually rename any occurrences you find. There will typically be two of them, oldfolder/prefix.pch and oldfolder/info.plist, but there may be others.
All done!
EDIT: this option is still there in Xcode 5, but is helpfully hidden by default. To show it, click the thin "Identity and Type" header in the inspector above the "Text Settings" panel to expand it.
I've done it dozens of times:
Rename the Project by clicking then editing the Title in your Xcode Project Navigator.
Close Xcode.
Rename the source folder.
From the Finder, open the .pbxproj file inside project bundle (context menu "Show Package Contents") with any text editor.
Search and replace any occurrence of the original folder name with the new folder name.
Save the file.
Open Xcode project.
Task:
Rename "Play" to "Play2" both in Xcode and in Finder
Change this:
To this:
STEPS:
// Before anything, please backup the project in Finder!
Rename project in Xcode Project navigator // Click project name then hit enter
Rename group in Xcode Project navigator // not affecting folder name in Finder
Close Xcode
Rename outer folder (left column in image) in Finder
// All above steps are straight-forward and without side effects
//
// Now comes the tricky part: rename the inner folder (middle column in image) in Finder (the one at the same level with .xcodeproj)
Rename the inner folder in Finder while keeping Xcode closed
Right click .xcodeproj, select "Show Package Contents"
Open .pbxproj file with Mac TextEdit
Search and replace all "Play" with "Play2". To guarantee everything goes right, click the arrow on the left end of the search bar and modify the search attribute. Change "Contains" to "Full word", and uncheck "Ignore case"
Save .pbxproj file
Open Xcode project and Run
Here is how to rename a project effectively in XCode4 (INCLUDING THE FILES FOLDER):
Close all open projects completely in XCode to prevent any issues
Copy the Project in question to a new Folder (IMPORTANT: KEEP A BACKUP OF YOUR OLD PROJECT)
Open the Project
Rename the Project itself in XCode4 (double click on the project name), change the name and follow the steps (yes to everything)
Go to product, manage schemes and rename the scheme (double click on the scheme name)
Close your project (make sure is completely closed otherwise the next steps will not work)
In Finder go to the Project folder and right click on the .xcodeproj file, then select the option "Show Package Contents"
Then right click on the .pbxproj file and open it with TextEdit
Replace all occurrences of the Folder Name where the projects used to live (The old project name for the new project name)
Save the file
Open the Project again and Build it!
First of - dont rename an Xcode project!!!
If you have to, the beneath could be it - I never got it to work, ended up creating a new project and started all over copying in the existing files. Xcode is so ahh.... It has so many non productive things, like also try renaming a file from "Name" to "name". Well, well have fun.
I found the answer or how to work around this: Open the pbxproj file by right clicking "Show Package Content" and in there you edit a project.pbxproj file - you have to rename a reference called path and some other stuff - just search for the folder name added "/".
That is it.
Hope it helps some one.
Here is another issue that you should be aware of while replacing values in your *.pbxproj file. If your old folder name was FooBar you will have an entry in your *.pbxproj file that looks like this:
path = FooBar
Suppose your new folder name is Foo Bar. That is, you are introducing a space. Then, this line should become
path = "Foo Bar"
If you just do a simple find and replace, the result will be a *.pbxproj file that Xcode can't parse. If your new folder name has a space and the old name didn't have a space, be sure to include the double quotes.
I am summing up for myself, after examining various answers above and trying myself.
Let's assume the current project name is ProjAbc and you want to rename it to ProjDef:
Exit Xcode of that project.
In Finder, Duplicate the folder ABOVE ProjAbc.xcodeproj for backup.
In Finder, Rename freely the folder ABOVE ProjAbc.xcodeproj if you feel you need it to suit new project name.
In Finder, Rename the source files folder parallel to ProjAbc.xcodeproj from ProjAbc to ProjDef
Open Xcode for ProjAbc.xcodeproj (in Project Navigator, all files in virtual source folder ProjAbc will be in Red color).
In Xcode, click on the (now broken) virtual folder in the Project Navigator in the left-hand sidebar and rename it to match the name in Finder - ProjDef. That won't yet fix the red files inside the folder, but that's OK.
In Xcode, (still selecting the virtual folder in the left-hand sidebar) in the right-hand sidebar, in the File inspector, click the icon shown in the screenshot below to bring up a file dialog. In the file dialog, select the folder that you previously renamed (ProjDef). This will re-associate the virtual folder with the real folder on disk, and will automatically fix the links to all the files inside.
In Xcode, in Project Navigator, click on the ProjAbc project name, and rename it to ProjDef.
You will be prompted: "Rename project content items?". Click "Rename" button.
You will be prompted: "Would you like Xcode to take automatic snapshots before Project Rename and similar operations?". Click either "Disable" or "Enable". It does not matter.
In Xcode, now open "Build Settings" inside ProjDef target (inside project ProjDef in Project Navigator). Rename both foldername and filename of both *-Info.plist and *-Prefix.pch files to contain ProjDef instead of ProjAbc.
In Xcode, in Project Navigator, in ProjDef virtual sources folder, in "Supporting Files", also rename again both *-Info.plist and *-Prefix.pch files to contain ProjDef instead of ProjAbc
In Xcode Menu, press Product/Scheme/Manage Schemes... (or click "ProjAbc"> Scheme name in Scheme Bar at left top of Xcode, and press "Manage Schemes...") and in the dialog box rename Scheme from ProjAbc to ProjDef, then press "OK" button. If Project name is composed of single word, you may run it just now!
In Xcode, edit the top comment line in Supporting Files/*-Prefix.pch file, and replace ProjAbc by ProjDef (2 times). Of course correcting this comment is optional.
Exit Xcode.
In Finder, point to ProjDef.xcodeproj and open it in text editor. (Either open it in TextWrangler.app , or, mouse right-click and in the pop-up menu press "Show Package Contents" then edit file project.pbxproj in TextEdit.app)
In the Text Editor, search "ProjAbc" (Entire Word, Match Case) which should appear once (in paragraph: /* Begin PBXNativeTarget section */ in line: productName = ProjAbc;) and replace it by "ProjDef". Indeed, project could run anyway!, so this step is optional.
if project name is composed of 2 or more separate words, like "ProjDef Geh", then you MUST do next steps: Search for the reference to the Finder folder of the virtual source files folder -
Search for the line: path = ProjDef Geh;
It will appear once, in paragraph /* ProjDef Geh */
Replace it by the line: path = "ProjDef Geh";
Save from text editor, and exit the Text Editor.
That's it. As written above, if project name is composed of single word, you can run right at end of step 11.
I found the above answers really useful, especially Nick Lockwood's answer.
I just renamed a couple of folders in Xcode 8 and encountered two more issues:
A) "missing from working copy errors"
B) Core Data crashes.
How to resolve these two issues:
A) "missing from working copy errors"
I found the below answer very useful: Swift 3 / Xcode 8 Upgrade - 100's of DerivedData files missing from working copy errors
Basically Xcode 8 has rigorous source control, which can lead to the above errors. You have to:
Clean Xcode derived data.
Go to Source Control and click Refresh Status.
Go to Source Control and click Commit; select all the files on the left sidebar of the commit menu when committing (right click -> Select All).
You'll probably get an error.
Close the Commit menu.
Refresh Status.
Close your project by quitting Xcode.
Reopen your project, refresh status, commit again.
This time the commit should work.
Click Project -> Clean.
I'm assuming that you have already enabled Source Control. If you haven't, or if you get stuck following my instructions, just follow the more detailed instructions in the link provided.
B) Core Data crashes
Renaming folders will sometimes screw up Core Data. There are several possible reasons why this is so, and below are some fixes I can suggest:
Incorrect AppDelegate model name. This was the case in my situation. Go to your AppDelegate and find let container = NSPersistentContainer(name: "YOUR CORE DATA MODEL NAME"). Make sure that the name is correct.
In the future (several years after this post, when Apple changes Core Data again) or if you're using an older version of Core Data, take a careful look at AppDelegate. There's probably something funky there that's messing with your Core Data.
Incorrect model name in xcdatamodeld. Go to Finder and open your .xcdatamodeld in a text editor.
Check the following:
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>YOUR CORE DATA MODEL NAME.xcdatamodel</string> <-- Make sure this is correct.
</dict>
</plist>
More detail here: Core Data model files does not load on rename
If the two things above don't work, try to 1) delete your entity and then add another entity that's identical or 2) delete your xcdatamodeld and then add another data model that's identical (and make sure that the name of the new xcdatamodeld matches what is in your AppDelegate and the rest of your code). Never do this with a live App - or if you do this, make sure to properly migrate your Core Data whilst doing so.
If you are have old reference of source project into your project, When dublicate the project (every change made affect to both proejct)
here the solution
Dublicate Project from source project
Rename source folder of source project that break reference issue.
In dublicate proejct everything goes red choose your current folder of project. (screenshot is shows in green tick answer of stackoverflow)
========================================================================

Resources