Xcode 不会放开资源文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2629747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:16:55  来源:igfitidea点击:

Xcode won't let go a resource file

iphonexcodefileresources

提问by user236739

My question today is about how Xcode deals with resource files in the app bundle which it creates. I know that it may be trivial, but I can't find an easy way out. Basically my problem is that Xcode seems to keep on including a resource file (eg a text file) in the app bundle even if the file has been removed from the project. Here it is in detail what is happening here.

我今天的问题是关于 Xcode 如何处理它创建的应用程序包中的资源文件。我知道这可能是微不足道的,但我找不到简单的出路。基本上我的问题是 Xcode 似乎继续在应用程序包中包含资源文件(例如文本文件),即使该文件已从项目中删除。这是这里发生的事情的详细信息。

?   Added a file to the project (both by choosing file - new file or dragging a file to the Xcode groups and files left column checking add to project folder if needed checkbox)
?   Compiled and launched the project in simulator
?   Verified that the file is present in myApp.app bundle, located in User/Library/Application/Support/iPhone Simulator/3.2/Applications/<application system number>/myApp.app and even in <my Xcode projects folder>/myApp/build/debugiPhonesimulator/myApp.app
?   Deleted the file from groups and files column in Xcode
?   Deleted the actual file with Finder in <my Xcode projects folder>/myApp/myFile
?   Deleted User/Library/Application/Support/iPhone Simulator/3.2/Applications/<application system number>/myApp.app and even <my Xcode projects folder>/myApp/build/debugiPhonesimulator/myApp.app
?   Emptied the trash
?   Verified that there is no reference to the file with Finder spotlight
?   Verified that there is no reference to the file with Xcode search
?   Rebuilt and relaunched the app in simulator
?   Verified that a brand new /Library/Application/Support/iPhone Simulator/3.2/Applications/<application system number>/myApp.app has been just created
?   Verified the content of /Library/Application/Support/iPhone Simulator/3.2/Applications/<application system number>/myApp.app bundle: the file is still there. Where the h. did Xcode take it from?

I am surely missing something really obvious. Any help?

我肯定错过了一些非常明显的东西。有什么帮助吗?

回答by Laurent Etiemble

Have you checked the "Targets" node ? If not then;

您是否检查过“目标”节点?如果不是那么;

  • Expand the "Targets" node and the application one.
  • There must be a build phase called "Copy Bundle Resources".
  • Check that the resource is not in the phase.
  • 展开“目标”节点和应用程序一。
  • 必须有一个称为“复制捆绑资源”的构建阶段。
  • 检查资源是否不在阶段。

You can also try to perform a full clean of the project to ensure that no temporary files stay.

您还可以尝试对项目进行全面清理,以确保不会留下任何临时文件。

回答by vdk

Clean used to work in xcode 3 but it doesn't seem to do a thing in 4. I found that deleting the app from the test device seems to help make the resource disappear.

Clean 曾经在 xcode 3 中工作,但在 4 中似乎没有任何作用。我发现从测试设备中删除应用程序似乎有助于使资源消失。

回答by PurnachandraObulasetty

Remove the app from the simulator and delete with finder the directory of your app in Library > Developer > Xcode > DerivedData.

从模拟器中删除应用程序,并使用 finder 在 Library > Developer > Xcode > DerivedData 中删除您的应用程序目录。

回答by Chuankai

I ran into a similar problem. Xcode 4 keeps complaining about missing resource file even though it has been removed from the project. It results in build error.

我遇到了类似的问题。Xcode 4 一直抱怨缺少资源文件,即使它已从项目中删除。它导致构建错误。

This is how it's resolved:

这是它的解决方法:

1) Open the .pbxproj file 2) Delete all the lines referencing the resource file that you want to get rid of 3) Build it

1) 打开 .pbxproj 文件 2) 删除所有引用要删除的资源文件的行 3) 构建它

回答by TechZen

Ran into a similar problem a few days ago.

前几天遇到了类似的问题。

It turned out that under 3.2, the simulator creates several application folders, one for each SDK version installed. I have:

事实证明,在 3.2 下,模拟器会创建多个应用程序文件夹,每个安装的 SDK 版本一个。我有:

~/Library/Application Support/iPhone Simulator/3.0
~/Library/Application Support/iPhone Simulator/3.1.2
~/Library/Application Support/iPhone Simulator/3.1.3
~/Library/Application Support/iPhone Simulator/3.2
~/Library/Application Support/iPhone Simulator/User

If you compile under a different SDK it creates a new application directory for the app within the folder for the new SDK. I had an alias to the old folder and ended up looking in the wrong folder at a version of the app that Xcode was no longer targeting and therefore never changing. IIRC, I had to track down the new app in the matching SDK folder.

如果您在不同的 SDK 下编译,它会在新 SDK 的文件夹中为应用程序创建一个新的应用程序目录。我有一个旧文件夹的别名,最终在错误的文件夹中查找 Xcode 不再针对的应用程序版本,因此永远不会改变。IIRC,我必须在匹配的 SDK 文件夹中追踪新应用程序。

回答by ffleandro

I had the same problem. However the solution proposed in the answer, didn't solve my problem. In the Targets > Copy Bundle Resources, I don't see the "ghost" files. I tried doing a full clean up, delete the app and reinstall it, and I still have the files in my app. The solution I found was by manually deleting the contents of the folder: ~/Library/Application\ Support/iPhone\ Simulator/4.3/Applications/

我有同样的问题。然而,答案中提出的解决方案并没有解决我的问题。在 Targets > Copy Bundle Resources 中,我没有看到“ghost”文件。我尝试进行彻底清理,删除应用程序并重新安装它,但我的应用程序中仍然有文件。我找到的解决方案是手动删除文件夹的内容:~/Library/Application\ Support/iPhone\ Simulator/4.3/Applications/

回答by mcornell

I had a similar problem with a .scnassetsfile - XCode Copy Resources only lists the .scnassetsfile (a real folder, not a group) but also remembers and copies it's contents even if they've been deleted. An intentional clean fixes this. Moreover, files deleted from a ghost .scnassetsfiles appear to be copied every time you run the app, instead of the first time they're needed. Cleaning speed my build time up by 300%!

我有一个与.scnassets文件类似的问题- XCode Copy Resources 只列出.scnassets文件(一个真实的文件夹,而不是一个组),但即使它们已被删除,也会记住并复制它的内容。故意清理解决了这个问题。此外,.scnassets每次运行应用程序时,似乎都会复制从幽灵文件中删除的文件,而不是第一次需要它们时。清洁速度将我的构建时间提高 300%!