File in the project not seen by Xcode after Git pull - xcode

A partner and I are managing an Xcode project via Git. He recently "localized" the project, which added a directory for German ("de.lproj") to the project with a number of files. After I pulled those changes over to my copy of the project, Xcode now fails to compile complaining that two files in this directory don't exist. These files are present in the filesystem, but displayed as red (missing) in the Xcode sidebar.
Is there a way to force Xcode to rebuild it's internal catalog of files so that it can "rediscover" that these files are, indeed, present?
Note, I've tried a fresh "clone" of this Git project as well, same result.

I found a solution without removing the file from Xcode -
In the Project Navigator, locate the file (colored red for not being found) and highlight it.
Show the File Inspector
Under Location change Absolute Path to Relative to group or Relative to project,
Then next to the path, there's a little white icon, click it and choose the file's location.

This turned out to be a case of absolute vs. group paths memorized in the project.pbxproj file by Xcode. For reasons I do not understand, when my partner localized our project, some files were added to Xcode using absolute paths. When I pulled that version of the project, my copy of Xcode could not find those files because the absolute path did not match my absolute path. Even though the files were in the project and transferred properly by Git, Xcode could not find them.
My solution was to use Xcode to delete these files. Since these were localized files, I actually had to delete the "parent" version of the localized files. I told Xcode to only remove the references to the files. Then I dragged the files from Finder back into Xcode. This time Xcode inserted them as "relative to group" and all was well.
I committed and pushed those changes back to our remote Git repository. My partner was able to pull those to his copy and all worked for him too.
Neither of us understand why the files were inserted as absolute references in the first place, but at least we were able to use this workaround to make the project portable again.

I had this issue and i fixed it just by quitting xcode and reopening it. All the missing files magically reappeared. Hope this will help some one.

Check the project folder path. If any of the folder name in the path contains a 'space' then remove it and open the project again. I had this issue with Xcode 9.

Related

Changing the name of main folder in Xcode project

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.

xcodeproj file is missing

I have folder where i store all my projects. I have problem with one of them.
All projects except this have projectname.xcodeproj file.
When i open Xcode i see this project - it has icon with white background (other have blue background). I can open it, build and run.
I can't find this .xcodeproj file - so i can't run pod init in terminal for this folder. I See error "No xcode project found, please specify one".
I don't use git. Searching for this file had no results. What else can i do?
I think you may have changed the path for the specific project you're experiencing problems with. Try to create another project and just copy/paste the files from the old project into the new one and reference the new project.

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

How to stop Xcode from thinking files are missing

I deleted some files from my project (a pair of .m/.h).
However now every time I build Xcode warns that the files are missing (though the build is otherwise successful).
I can't see where/how Xcode thinks the files are needed, it must have some reference to them somewhere but I can't find it - the files are not listed in either the compile sources section nor the copy bundle resources section. Where else might they be listed such that Xcode feels the need to warn about them not being physically present?
To delete them try this:
create a file named like the missing one
copy this file into your project folder, so that Xcode recognizes it
right click on the file inside Xcode in the project view
select delete
select move to trash, when Xcode asks
This worked for me for files, however I have the same problem with empty folders. If somebody knows a way to get rid of the missing warning for them, please comment.
If the files are missing from the project navigator or your checkout, but not included in the build for the current target, then the build might succeed despite the warnings.
XCode's Project Navigator keeps track of files, the directory they're in, and the state in git or svn. The project warnings when opening a project are shown in the status view at the top of the window. You can review these warnings when you press command-4.
The project navigator marks files that it tracks, but that it cannot find, in red in the folder view (press command-1 for that view). If you see red file names it might be that you deleted or moved them into another folder without XCode knowing about that. Then select the red filename and delete it.
On top of this the files might be "missing from your work copy", but still present in the repository. You can do two things in the terminal to sync with or delete the file from subversion.
svn up file
svn rm --force file

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.

Resources