Xcode duplicates files in a project

I have a total loss of what I did to cause this: The second time I started using Xcode about a month ago (my first time seriously used it after I took one class a few years ago), I try to start my project , and the next thing I know, I have errors because I have duplicate links. I looked at the project, and it turned out that most of the files in my project were duplicated, however I found that they do not duplicate files, but duplicate links. It happened to me today when I first tried to build a real iphone, but it happened to me a few weeks ago when using the simulator. I never remember anything unusual. I built and tested the project, probably more than 100 times, and usually everything goes fine. I was able to fix this for the first time, but I think this time I made it worse, and I will probably add files back to the new project. My colleague also mentioned this with him (he has as much experience with xcode as mine). He told me that in the end he ended up in files nested in folders (groups?) Nested in other folders about 20 inches in size.

My question is: does anyone know what I might have done to trigger this. I would very much like to avoid this problem in the future, since it turned out to be quite a headache. Any advice would be greatly appreciated.

ETA xcode version 4.6.2 (possibly an earlier version on first launch)

+4
source share
4 answers

Try this instead:

  • Select all duplicate files
  • Right-click on one of the files and click on "Delete"
  • When prompted to indicate which deletion option, click "Delete Link"
+2
source

You also asked for "any advice." If you are not already using the source git control in Xcode projects, get started now. You can detect many bugs like this one earlier and ease them with git.

When you add files as a copy, the Xcode project navigator shows the added files with A and modified files with M.

Modified and Added files

If the file is inside a private group folder, the folder shows A.

Added file copy inside closed group folder

If you add the link without a copy, the project navigator will not display A, but MyApp.xcodeproj will show M.

In Xcode, you can discard the change before executing it. In the case below, you must discard changes to all files added or changed.

discard changes

Usually you often review and commit changes. Using a gui tool such as SourceTree, you have a good chance of detecting a random change before committing. For example, you can see the changes in the project file.

SourceTree, a gui for git

If you accidentally commit an unintentional change, you can come back later and cancel the commit. Often by committing, you have more control over which changes you cancel and which ones you save.

Literature:

http://www.raywenderlich.com/13771/how-to-use-git-source-control-with-xcode-in-ios-6

http://git-scm.com/doc (scroll down to view the video)

http://www.sourcetreeapp.com

http://gitimmersion.com

+1
source

I had the same 20 deep sockets in my main image folder. If this is not a mistake, this is a very strange behavior. I just supported it all! Then I opened the folder in finder, found the point at which he began to insert and delete it.

I did a recreation, but I don't think Xcode even noticed. This did not make any difference to the size of my application, so Xcode did not put unnecessary files into the binary.

0
source

This happened to me when I imported the file. Suddenly, I had two subdirectories containing copies of all my files. The compiler complained about repeating classes.

I found a solution, but it is a ball and a shell.

1: click on your project in the navigator to open the project settings in the main window.

2: Open the source compilation accordion record. (This allows you to see which files are used in the compilation process.)

3: Find all duplicates here and delete them. (At this point, your project should compile again.)

4: In your navigator, slowly, double-click one of the files that are duplicated there. This should allow you to rename it. Change the name slightly (not the extension).

5: You should notice that the copy turns red. Select it and click "Delete." (This avoids the delete operation by deleting the file from Compilation Sources)

6: Rename the source file back to the original name again.

7: Repeat from 4 until you're done, or until you get bored.

8: Explain to your boss why a simple copy change took half a day.

This process can be optimized by first renaming all duplicate files, and then deleting duplicates immediately. However, this means that you cannot verify successful compilation between steps, which allows you to narrow down the culprit to one file. And it takes even more time.

If compilation failed, make sure that all the necessary files are still in the "Compile Sources" section, as this process may lead to their loss. The compiler usually gives some reasonable errors regarding missing classes and variables, but missing AppDelegate will lead to a more confusing error.

0
source

Source: https://habr.com/ru/post/1482053/


All Articles