Xcode- 删除的图像出现在模拟器中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8821316/
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 22:58:21  来源:igfitidea点击:

Xcode- Deleted images appear in simulator

xcodexcode4xcode4.2

提问by jsherk

Mac OS X Lion v10.7.2 Xcode v4.2.1 Build 4D502 gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00) GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Thu Nov 3 21:59:02 UTC 2011)

Mac OS X Lion v10.7.2 Xcode v4.2.1 Build 4D502 gcc version 4.2.1(基于 Apple Inc. build 5658)(LLVM build 2336.1.00)GNU gdb 6.3.50-20050815(Apple 版本 gdb-1708)(Thu) 2011 年 11 月 3 日 21:59:02 UTC)

I have a bunch of images in my resource folder, but when I delete those images and run in simulator again, the images are still there. I have completely deleted the images from the Project Editor window (not from Finder), and I used DELETE (not Remove Reference Only), and they are still showing up in the simulator. If I add new images back in (with the same names) thru the Project Editor window (not from Finder) the old ones are still being used as well instead of the new ones.

我的资源文件夹中有一堆图像,但是当我删除这些图像并再次在模拟器中运行时,图像仍然存在。我已经从项目编辑器窗口(不是从 Finder)中完全删除了图像,并且我使用了 DELETE(不是仅删除引用),它们仍然显示在模拟器中。如果我通过项目编辑器窗口(不是来自 Finder)将新图像(具有相同名称)添加回,旧图像仍然会被使用,而不是新图像。

I have tried:

我试过了:

1) Deleting images from Project Editor window.

1) 从项目编辑器窗口中删除图像。

2) Delete app from simulator (click and hold, then delete while wobbling), then restart computer.

2)从模拟器中删除应用程序(单击并按住,然后在摆动时删除),然后重新启动计算机。

3) Choosing Product > Clean.

3) 选择产品 > 清洁。

4) Choosing Product > Option+Clean.

4) 选择产品>选项+清洁。

5) Choosing Show Package Contents of .xcodeproj file, and deleting everything in the xcuserdata folder.

5) 选择 Show Package Contents of .xcodeproj 文件,并删除 xcuserdata 文件夹中的所有内容。

This is an incredibly annoying bug!

这是一个令人难以置信的烦人的错误!

How do I tell Xcode to stop using cached images?

如何告诉 Xcode 停止使用缓存图像?

I am newbie, so something like "Clean Targets" does not mean anything to me, unless you give me the instructions on how to do it as well.

我是新手,所以像“清洁目标”这样的东西对我来说没有任何意义,除非你也给我关于如何做的说明。

Thanks

谢谢

EDIT:

编辑:

Here is another option we all missed, which might do the same thing as deleting the /Simulator/../Applications folder: In the iOS Simulator menu, there is an option called Reset Content and Settings ... it never occured to me that the simulator was a separate app from Xcode, so I never thought to check menu items while simulator had focus!

这是我们都错过的另一个选项,它可能与删除 /Simulator/../Applications 文件夹的作用相同:在 iOS Simulator 菜单中,有一个名为“重置内容和设置”的选项......我从来没有想过模拟器是一个独立于 Xcode 的应用程序,所以我从没想过在模拟器有焦点时检查菜单项!

回答by mvds

Manually removing the build folder may help. Clean does not always do this properly, for reasons unknown. The build folder used to be in the project directory, but now (also) exists in ~/Library/Developer/Xcode/DerivedData/

手动删除构建文件夹可能会有所帮助。由于未知原因,清洁并不总是正确地执行此操作。build 文件夹曾经在项目目录中,但现在(也)存在于~/Library/Developer/Xcode/DerivedData/



Solved by original poster:

由原海报解决:

Oh wait I had a brainstorm because of your suggestion above, and from Terminal I used: find . -name 'myimage.png' 2> /dev/null and I found the secret hidden cache! It is in my user library here: ~/Library/Application Support/iPhone Simulator/4.3.2/Applications/ Just delete everything in the Applications directory. May also need to do this one as well: ~/Library/Application Support/iPhone Simulator/5.0/Applications/

哦等等,由于您的上述建议,我进行了一次头脑风暴,我使用了终端: find 。-name 'myimage.png' 2> /dev/null 我找到了隐藏的秘密缓存!它在我的用户库中:~/Library/Application Support/iPhone Simulator/4.3.2/Applications/ 只需删除 Applications 目录中的所有内容。可能还需要这样做:~/Library/Application Support/iPhone Simulator/5.0/Applications/

回答by Hymanal23

I had the same thing when I was adding transparent background to an image that was already part of the project.

当我向已经是项目一部分的图像添加透明背景时,我遇到了同样的事情。

What worked:

什么工作:

1) Delete app from Simulator (long press and hit X).

1) 从模拟器中删除应用程序(长按并点击 X)。

2) Also I had to remove old image files from project and then reload the new transparent background images into the project.

2)我还必须从项目中删除旧的图像文件,然后将新的透明背景图像重新加载到项目中。

Also hit Project > Clean multiple times.

还多次点击 Project > Clean。

回答by Vincent

I had the same. Very strange because the simulator displayed the no longer existing images and the development-phone displayed the correct images.

我有同样的。很奇怪,因为模拟器显示不再存在的图像而开发手机显示正确的图像。

I had already removed them from the folder. And deleted them from the simulator. For me a Product > Clean did the trick.

我已经从文件夹中删除了它们。并从模拟器中删除它们。对我来说,产品 > 清洁做到了。

回答by Tom Tallak Solbu

After I did the "remove fromfolder"/"Reset content and setting"/remove app from simulator", I still had an old image hanging around in the simulator. Then I did a "Project>clean". Then the detailViewController.xib file disappeared from the folder. It is still present in XCode, but can not be found anymore when running the app in the simulator, cousing a crash. What is the problem here?

在我做了“从文件夹中删除”/“重置内容和设置”/从模拟器中删除应用程序之后,我仍然有一个旧图像挂在模拟器中。然后我做了一个“项目>清理”。然后是detailViewController.xib文件从文件夹中消失了。它仍然存在于XCode中,但在模拟器中运行该应用程序时再也找不到了,发生了崩溃。这是什么问题?

回答by Mike M

I believe that since Lion, this has changed to '/Users/[user name]/Library/Application Support/iPhone Simulator/[version number]**'. Be careful however, the Library folder is hidden. To view it, open the Terminal and run this:

我相信自从 Lion 以来,这已更改为' /Users/[用户名] /Library/Application Support/iPhone Simulator/[version number]** '。但是请注意,Library 文件夹是隐藏的。要查看它,请打开终端并运行:

defaults write com.apple.Finder AppleShowAllFiles YES

回答by Ryan Heitner

I had to

我不得不

1) Delete the images from the folders.

1) 从文件夹中删除图像。

2) Delete the app from the simulator.

2) 从模拟器中删除应用程序。

3) Clean.

3) 清洁。

4) Stop the simulator and restart.

4) 停止模拟器并重新启动。

Only when I had done each of these could I get rid of old resources

只有当我完成了这些,我才能摆脱旧资源

回答by Brian Broom

I had this issue as well. Deleting the app from the simulator (In the simulator do Hardware -> Home, click + hold on app icon till icons jiggle, click the x just like you would do on a device). Running again used the correct images.

我也有这个问题。从模拟器中删除应用程序(在模拟器中执行 Hardware -> Home,单击 + 按住应用程序图标直到图标抖动,就像在设备上一样单击 x)。再次运行使用了正确的图像。

回答by marekventur

Running sudo rm -rf ~/Library/Application\ Support/iPhone\ Simulator/7.*/Applicationsfixed the problem for me. You might have to change the 7, depending on which version you'll have in ~/Library/Application Support/iPhone Simulator

跑步sudo rm -rf ~/Library/Application\ Support/iPhone\ Simulator/7.*/Applications为我解决了这个问题。您可能需要更改7,具体取决于您将使用的版本~/Library/Application Support/iPhone Simulator