No such file or directory after removing a duplicate subdirectory

让人想犯罪 __ 提交于 2019-12-10 12:57:11

问题


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.


回答1:


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.




回答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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/6333840/no-such-file-or-directory-after-removing-a-duplicate-subdirectory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!