Renamed Files Still Exist in Xcode - iphone

I'm making an iphone app that displays a random picture chosen from pictures in Resources.
I have renamed some files for categorization,
but running console shows that file with a new name and file with old name both exist as separate files.
Of course, I can't see the file with the old name in my Resource folder, nor in the original folder where the pictures are.
Kinda freaky...
How could I remove the files with old names and make it a norm to not keep another file with the old name whenever I rename a file?
Please help me out.
Thanx.

Expand your Target and remove the images from Copy Bundle Resources.

I'm not sure I understand your question correctly, but I recommend cleaning your targets from the project menu and resetting the simulator.
You can also select all the new files in XCode, right click and select compile.

Related

Xcode not allowing to copy files to bundle

I am having problem in copying files to Xcode bundle.
I have some files in my bundle and i am trashing them and copy new same named one from another project.
But regularly Xcode giving error as : Multiple errors occurred while copying the files.
I have done much RND but no solution.
Can anybody help me out.
Thanx in advance.
Because you just deleted files from your project but one copy of each file is still in folder where your project is. Delete all red lines first if there is any. And see below steps -
Right Click on your project
Show in finder
Find your files and delete them
Now delete all red line files
Command+shift+k clean your project.
Now add new files.
I realize this is an old post but am adding here in case others run into the same issue. I was working on a project where I utilized AFNetworking and performed the following steps:
I dragged and dropped the files into my project and asked xCode 5 to make a copy of the same (rather than create a reference).
I needed to delete the folder/files I just imported and right clicked on the same in the file navigator in xCode and hit Delete - I did delete the folder/files in the manner laxonline describes above.
Attempted to re-add the AFNetworking library code back into my project and got the below message.
The fix here is to follow the steps in the accepted answer - i.e. To right click on your project in xCode, select Show in Finder and then delete the offending files/folders.
I upvoted the accepted answer but am also posting this as a separate answer so I can highlight that the above can occur even if you select the correct delete option. In my case, I discovered that while the AFNetworking files were no longer in the directory, an empty folder with said name still existed.
While deleting the exicting files from Xcode. The Xcode4 asks you "Do you want to permanently delete the file “fileName” from disk, or only remove the reference to it?"
By default the alert selects "Remove Reference Only"
Change it to Delete.
while deleting files you must select move to trash option.
If you select Remove References then only the link to those files gets removed and you will have to manually delete those files from their location.

Xcode 4 embedded resource prevention

In XCode4, is there a way to have a 'resource' (i.e. a CSV used to load a sqlite database) that is there for project purposes, but not have it compiled into my project? So my final app doesn't include it? I can't seem to see to to have this facility.
Thanks
Assuming you do not want the file get into your .app file, One solution i can think of is, do not include 'Target' when adding the file to the project. If you want to exclude your already added file then
Choose the target
Go to Build phases
Expand copy bundle resources
Select your resource file and remove it.

groups and files in XCode vs. project folders in Finder

I still can't get the idea that when I create a new Group in XCode, and build the project, and then return back to finder and notice that the group does not exist but any file to be created under this group will appear in the project's directory in finder but that file is alone without being under any group.
(note: I'm not talking about this directory: /Users/username/Library/Application Support/iPhone Simulator/4.3/Applications/uuid/...)
1) can anyone explain why project's directory hierarchy in finder is different from the project's directory hierarchy in XCode ?
2) how can I make the two hierarchies looks like exactly the same between XCode and Finder? so when I create a new Group in future I can see it in finder.
thanks in advance.
Currently you cannot see the group you create in Xcode in finder. Its just a logical entity for you to organise your projects in a better way. Assuming you will be using xcode to make all the changes (including version control) you can use that categorisation and make sense out of it in Xcode.
However you always have the option of creating a folder in finder(your project workspace) and create files and save them in that folder using Xcode. This is particularly helpful for viewing organized code while browsing through the file system. Also you can group files into folders which you can then use across projects.
So basically it boils down to what your use case is. As for me i am happy using xcode. I usually create a directory to hold images and copy directories for libraries into my project folder so that there is clean organisation in the file system too.
Another helpful method is after you create the group in Xcode, but before you put files in it, check the File Inspector pane on the right with the group selected. Make sure Location is set Relative to Group and then click on the folder icon below that. This will bring up a Finder window. Then, make a directory with the same name, and click Choose. Now, anything you put in that group will go in that folder of the same name.
Simple solution is that you make the require folder in Finder, then go to Xcode. In navigator, right click and select "Add files to" option, add the that folder. It will be added to your navigator as well. Now whatever you add to that group, it will be automatically added to your folder in finder as well.

How do I properly add existing source code files to my Xcode project?

I'm new to iPhone development and I'm still getting familiar with the Mac dev environment, including Xcode. I want to add some 3rd party code to my iPhone project, but when I add the "existing files" to my Xcode project, I'm presented with a dialog box that has far too many options that I don't understand and, as such, my project isn't working. When I #import headerfilename.h, I get a build error that reads headerfilename.h: No such file or directory.
alt text http://joecrotchett.com/images/misc/fileadd.jpg
Can anyone explain to me what all these options mean or give me a link to some documentation that can? I'm having a hard time finding anything in Apple's docs.
Which options do I want to choose to add existing source code files to my Xcode project? I should note that the source code files that I'm trying to add are located in my project/Classes/frameworkname/ directory.
After they're added, do I need to reference this new code directory in my project settings anywhere (i.e. some kind of header file directory variable)?
Thanks so much!
Update: I found the following answers/responses on the apple dev forums that were very useful and helped me fix my issue...
To make it simple :
- if you do not check the copy option, the file stay where it is.
- if you check it, it is copied in your project folders In the first case
(what it seems you are doing) you need
to tell the compiler that the header
files are in another directory :
- project info -> build -> search paths -> User Header Search Path : add
the directory from where you took the
header file Hope this will help
You have discovered the most confusing
dialog box that ever came out of
Cupertino. Six years of Xcode, and
this thing still is partly a mystery
to me. To even get that far, I had to
make many test projects to try and
reverse-engineer what this thing does.
The "Copy" box means that it will copy
the files as they are right now, into
the project. If this box is not
checked, then it just references those
files during a build and copies them
as they are at THAT time. For source
code, you want the Copy box checked.
The "relative to" is a total mystery
to me and I can't help you with that.
I usually leave it however it is
already set. Does it mean relative to
where they are on disk, or the
arrangement in Xcode, or in the
bundle? Who knows. The last 2 radio
buttons SEEM to mean that it will
either re-create the folder structure
of the folder you are adding, or just
put "fake" folders in Xcode that point
to the real folders. This is probably
your problem - you are adding source
code that is not all at the top level,
and when it goes to find it, it does
not re-create the hierarchy. Others
can supply a better way, hopefully,
but what I would do is put all of the
source in one folder and add that,
using the Copy box. Then in Xcode you
can make whatever bogus folders you
want and put the source file names in
those fake folders.
This is from the Xcode user guide:
"The project navigator shows projects, groups, folders, and files:
The project or projects in your workspace window are the highest level
of the hierarchy in the project navigator. Open the project’s
disclosure triangle to see the groups, folders, and files in the
project. Select the project to display the project editor, where you
can view and edit project and target settings.
A group appears in the project navigator as a yellow folder icon. The
group does not represent a folder on disk. Although you can organize
your project in Xcode to reflect the organization of files on disk,
moving files into and out of groups does not affect the content of the
folders on disk, and moving files on disk into and out of folders does
not affect the content of the groups in the project navigator.
A folder is a reference to a folder on disk and appears in the project
navigator as a blue folder icon. The contents of the folder in the
project navigator reflect the contents of the folder on disk. It’s
important to note, however, that the files that appear in a folder
icon in the project navigator are not part of your project unless you
have added them to the project explicitly (in which case they appear
directly under the project or in a group, as well as in the folder).
You can view and edit the files in a folder, but to move files in and
out of the folder you must use the Finder.
A file in the project navigator is a reference to a file on disk."
I think usually the default option is the best one. If you want to add into some group, you can tick on the "Copy Item to Destination group"
You don't have to change any project settings after adding
And if you want to add the whole framework code, please choose add existing framework
Copy items into destination group's
folder (if needed)
Well, only if you want it to copy the files. If you are happy with their existing location and don't want it to copy them, don't select it (that's what I do).
Reference Type:
A total mystery to me
Text Encoding
Self explanatory
Recursively create groups for any
added folders Create Folder References
for any added folders
Leave this as the default and then organize the folders in your Xcode project any way you want.
Add to targets
If you add an additional target to your project, e.g. for iPhone vs. iPad versions, then not noticing that it has by default added the files to just one of them (at random?) can cause headaches.
Also, make sure you add the new header directory to your search paths in Project Settings > Build > Search paths. I think that's what's causing your problem.
Hope this helps, I remember how confusing this was to me at first.
If you want to add an Framwork Bundle, just add is as one. Add -> Existing Frameworks

How do I consolidate my Xcode project files?

When I started working on my first app, i assumed dragging files into xcode put them in my project's actual directory. Not so. Apparently Xcode references them all on the desktop.
Is there an easy way to copy all referenced files into the project directory? My desktop is a mess.
Use the Finder to relocate all the files to where you want them. Then, open your Xcode projects, and for each file that's missing (shown in red), use the Get Info command and edit the path.
There really isn't a straightforward way to do this once you've added the references to the Xcode project.
One solution (although tedious and slightly scary) is to remove the references from Xcode and re-drag these files into your project with the "Copy files..." option checked.
Even when you check the "Copy files ..." checkbox when you drag your files in, it's done "When necessary", without telling us when it thinks it's deemed not necessary to copy the files. I'd find that the best way to check if a bundle is self-contained is to compress it to .zip (the entire folder), move it to a temp folder, decompress and then go through all the files, or simply compile and run.
It's amazing that Xcode doesn't have a consolidate function like iTunes does.
From Xcode, you can right-click the project and select "Add -> Existing files..." When you have selected all your files, click "Add," then select the check box at the top "Copy files..."