如何让Xcode刷新项目图像文件的本地副本?

时间:2022-09-16 19:03:48

I'm having some weird issues with Xcode, and this is pretty much impossible to find answers by simply googling around.

我对Xcode有一些奇怪的问题,通过谷歌搜索来找到答案几乎是不可能的。

I have a few icon image files (just PNGs) in my Xcode project, and when I modify some of them in Photoshop, they don't get updated when I do another build in Xcode. In order to fix this I have to re-add the file again to the project, and then remove the old version of the file that is already in there in Xcode.

我的Xcode项目中有一些图标图像文件(只是PNG),当我在Photoshop中修改其中的一些时,当我在Xcode中进行另一次构建时,它们不会得到更新。为了解决这个问题,我必须再次将文件重新添加到项目中,然后删除Xcode中已存在的旧版本文件。

What am I doing wrong here? I'm updating/replacing the image file that is stored in my project's directory directly from Photoshop, so I assumed that it would just get reloaded and the new version would show up.

我在这做错了什么?我正在直接从Photoshop更新/替换存储在我项目目录中的图像文件,所以我认为它只会重新加载并且新版本会出现。

UPDATE: Looks like what happened was that when I first imported the image files into my project, they got added to my "Classes/" sub-directory. So when I was updating them, it was just adding them to the root of my project.

更新:看起来发生的事情是,当我第一次将图像文件导入我的项目时,它们被添加到我的“Classes /”子目录中。因此,当我更新它们时,它只是将它们添加到我的项目的根目录中。

2 个解决方案

#1


That's pretty weird. I'd suggest two things:

这很奇怪。我建议两件事:

  1. Check that you're not saving your photoshop files into the wrong directory. I know this seems straightforward but its worth a check. Make sure you're not saving them into the build/ directory or anything like that.

    检查您是否未将photoshop文件保存到错误的目录中。我知道这似乎很简单但值得一试。确保你没有将它们保存到build /目录或类似的东西中。

  2. Before running again in the simulator, try cleaning all build targets first to ensure that your project actually builds again before launching the simulator.

    在模拟器中再次运行之前,请先尝试清除所有构建目标,以确保在启动模拟器之前实际构建项目。

#2


I had the exact same problem. The following fixed it for me: In Xcode, go to Project --> Clean

我有同样的问题。以下修复了它:在Xcode中,转到Project - > Clean

This will purge the old images from xcode cache and will show your new image

这将清除xcode缓存中的旧图像,并显示您的新图像

#1


That's pretty weird. I'd suggest two things:

这很奇怪。我建议两件事:

  1. Check that you're not saving your photoshop files into the wrong directory. I know this seems straightforward but its worth a check. Make sure you're not saving them into the build/ directory or anything like that.

    检查您是否未将photoshop文件保存到错误的目录中。我知道这似乎很简单但值得一试。确保你没有将它们保存到build /目录或类似的东西中。

  2. Before running again in the simulator, try cleaning all build targets first to ensure that your project actually builds again before launching the simulator.

    在模拟器中再次运行之前,请先尝试清除所有构建目标,以确保在启动模拟器之前实际构建项目。

#2


I had the exact same problem. The following fixed it for me: In Xcode, go to Project --> Clean

我有同样的问题。以下修复了它:在Xcode中,转到Project - > Clean

This will purge the old images from xcode cache and will show your new image

这将清除xcode缓存中的旧图像,并显示您的新图像