No such file or directory after removing a duplicate subdirectory
Asked Answered
L

4

7

My app was building and running fine on the simulator and device, but I noticed that for some reason, I had a duplicate directory within my main directory, and some duplicate files as well. So while my main directory was /MyAppName, there were also files in /MyAppName/MyAppName.

I carefully moved any non-duplicate files out of the subdirectory, deleted the directory, and updated the paths for my Prefix Header and Info.plist files. I cleaned and built the project, however I'm still getting an error from the compiler looking in the duplicate subdirectory (which is deleted), like so:

arm-apple-darwin10-llvm-gcc-4.2: /MyAppName/MyAppName/main.m: No such file or directory

because main.m is now in /MyAppName/main.m

I don't see a variable or setting to look for other than the Prefix Header and Info.plist files. Is there somewhere else I should look? Clearly something is still referencing the duplicate subdirectory, but I don't see where.

Lyall answered 13/6, 2011 at 17:20 Comment(0)
T
4

From your description of the project layout it sounds like this is an Xcode 4 project. Xcode's project configuration still thinks that main.m is in /MyAppName/MyAppName, so you need to update the project configuration for this file and any others.

Select main.m in the Project Navigator (left panel) and open the File Inspector (right panel). Under the Location heading on the File Inspector, click the button that looks like a small window with a document icon; this will allow you to update the project's path for main.m. Repeat with other files. Depending on how many files you have it may be easier to just remove them from the project (using the project navigator), being sure not to delete them, and then add them back to the project again.

You probably ended up with files at different levels of the filesystem hierarchy because when you create a new file, Xcode uses the selection in the Project Navigator to determine where to put it on disk. If you have the project selected, the file will go in the top level folder; if you have group selected, it will go in whatever folder is associated with that group, or one of its parents.

Transposal answered 13/6, 2011 at 19:37 Comment(1)
After regrouping files, resetting the path didn't work for me. When I followed Adam's suggestion to remove the file from the project and add it back -- which worked -- I noticed that the file's Location popup now said "Relative to Project," rather than "Relative to Group." Just changing this did the trick for other problem files.Bridging
P
2

I had this problem when moving files around in my project. Go to the project's build settings and search for main.m. Then fix that setting.

Pastis answered 13/6, 2011 at 19:42 Comment(0)
B
2

I had a similar problem (after moving files); and could not determine where the setting was which was insisting that main.m was in an old folder. main.m appeared correctly in the project tree, was referenced correctly, included in the project, etcetera; but the build was insistent on using the old location.

I was able to resolve the issue by removing main.m from the project and re-adding it. I also recommend doing a full clean (cmd-opt-shift-K) and build.

Ballplayer answered 26/8, 2011 at 17:23 Comment(0)
O
0

Not sure what version of Xcode you're using but if you're on 3.x did you use "Empty caches" (Xcode menu) to make sure any intermediate files were removed prior to building? Sometimes cleaning the target doesn't do the trick.

Also, you could try removing the offending files from the project and re-adding them from the correct path.

Ockham answered 13/6, 2011 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.