Clean Build and references - xcode

This seems pretty straight forward but how do I update a build or maybe whats it called "clean"? Basically sometimes I will move a .H and .M file to a new folder in xcode project navigator. In xcode it shows the files have moved but in Finder the are not moved into the new folder thus in xcode I still have to reference files (like #import "blank") as if it was in the original location even though it shows the files are moved in Xcode. This seems to be the case if I delete files xcode fails cause it is say the file is still there. Does cleaning update the build references??

xcode groups and the filesystem are not 'connected'
moves of files in xcode don't affect where files are / need to be on the filesystem and vice versa.
what I always do is move files on disk, then REMOVE and READD them in xcode

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.

Can't delete or rename files in Xcode 4.6 Project Navigator?

Something has become buggered with my project.
I can't delete files or rename files from Project Navigator view.
It may have something to do with source control? If I highlight 5 files in Project Navigator and hit delete and then move to trash the first file gets a source control "D" marking beside it but all of the files still remain.
Restarting mac/xcode has not resolved it. Any ideas?
Same thing happens to me for a while now.
Using git.
So far I'm able to work around this by deleting the files one at a time, which moves the file to trash but doesn't remove the reference. And then deleting the references again.
Similar problem with adding files to the project and renaming them.
For adding: first move/copy the required file in the project folder to the desired location, and then add from Xcode deselecting the "Copy items..." checkbox.
For renaming: find file in finder, rename IN FINDER, then change the name accordingly in Xcode (or choose the file again from the right panel).
Hopefully we won't have problems like these after moving to Xcode 5.

File listed twice in xcode

I'm working on an iPhone project in Xcode and I'm using github as a repository. Recently, after a series of pushes and pulls from the repository, some of the files in the project are listed twice in Xcode. What I mean by this is that in the left panel of Xcode where it shows all of the files in the project, some of the files are listed twice.
I've done some experiments and the repeated files seem to be merely references to the same underlying file. If I change ViewController.h the same changes appear in the other listed ViewController.h file. Similarly, if I delete on the listed occurences, both of the copies disappear.
I've tried restarting Xcode, deleting the derived data and re-cloning
The Xcode project browser is just a collection of links to files and/or folders. If you right-click on each instance of ViewController.h and choose "Show in Finder", they will likely both point to the same real file on your computer.
If that's the case, you can safely delete one of them from Xcode without any ill effects. Just make sure to do the default "Remove Reference" and not "Move to Trash".

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

File in the project not seen by Xcode after Git pull

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.

Resources