ios 我如何解决这个 CopyPNG 文件错误?

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

How do i fix this CopyPNG File error?

iosxcode

提问by Daniel Medina Sada

While reading /Users/user/Desktop/AppProject/PruebaApp/LogoRetina.png

在阅读/Users/user/Desktop/AppProject/PruebaApp/Logo Retina.png 时

pngcrushcaught libpng error:

pngcrush捕获 libpng 错误:

Read Er Could not find file: /Users/user/Library/Developer/Xcode/DerivedData/PruebaApp-cblepoaxbqzyopcbcswwqjtftyon/Build/Intermediates/ArchiveIntermediates/MaderoAPP/InstallationBuildProductsLocation/Applications/MaderoAPP.app/Logo Retina.png

Read Er 找不到文件:/Users/user/Library/Developer/Xcode/DerivedData/PruebaApp-cblepoaxbqzyopcbcswwqjtftyon/Build/Intermediates/ArchiveIntermediates/MaderoAPP/InstallationBuildProductsLocation/Applications/MaderoAPP.app/Logo Retina.png

Command

命令

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng emitted errors but did not return a nonzero exit code to indicate failure

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng 发出错误但未返回非零退出代码以指示失败

Im getting these errors while archiving project, at the end it does archive but i want to get rid of it. I had trouble with the app before and i read that i should delete the DerivedData/(myproject)folder so i did. and apparently it is trying to look for the images in that folder how do i fix this??? Help!

我在归档项目时遇到这些错误,最后它确实归档了,但我想摆脱它。我之前在应用程序上遇到了问题,我读到我应该删除 DerivedData/(myproject) 文件夹,所以我这样做了。显然它正在尝试在该文件夹中查找图像我该如何解决这个问题???帮助!

回答by Stormer

Try first by Hard Cleaning your project CMD+OPTION+SHIFT+K, If problem exists apply following method,

首先尝试硬清理您的项目CMD+OPTION+SHIFT+K,如果存在问题,请使用以下方法,

Build Phases-> Copy Bundle Resources, Any fileName is red color?

Build Phases-> Copy Bundle Resources, 任何文件名都是红色的?

Or

或者

Convert Logo Retina.png or Create it again, maybe it's an encoding\format issue.

转换 Logo Retina.png 或重新创建,可能是编码\格式问题。

Or

或者

Rename "Logo Retina.png" to "LogoRetina.png".

将“Logo Retina.png”重命名为“LogoRetina.png”。

~Good luck~

~祝你好运~

回答by Anup

It also happens when you have multiple images with the same name in TARGET->Build Phases->Copy Bundle Resources. To resolve it -

当您在TARGET->Build Phases->Copy Bundle Resources 中有多个同名图像时,也会发生这种情况。要解决它 -

  1. Search for the image name that you are getting an error for in Build Phasessearch bar at the top.
  2. If you get multiple results in Copy Bundle Resourcesfor the search query, just remove others from it by clicking on "-" sign. Make sure you have same images for the multiple results. If not you have to rename the actual files of other entries.
  3. Just compile your code. You are good to go.
  1. 在顶部的构建阶段搜索栏中搜索您遇到错误的图像名称。
  2. 如果您在搜索查询的复制捆绑资源中获得多个结果,只需通过单击“-”号从其中删除其他结果。确保多个结果具有相同的图像。如果不是,您必须重命名其他条目的实际文件。
  3. 只需编译您的代码。你已准备好出发。

Hope it works for you.

希望对你有效。

回答by Evgeny Mikhaylov

Just open image in Preview app and export it as png file. Replace old image with new in Xcode.

只需在预览应用程序中打开图像并将其导出为 png 文件。在 Xcode 中用新图像替换旧图像。

回答by deepwinter

Honestly I have had this problem intermittantly many times and clean then rebuild has fixed it.

老实说,我间歇性地遇到过这个问题,清理然后重建已经修复了它。

回答by LinusGeffarth

Since the answers here are either not useful at all or quite complicated I want to add mine:

由于这里的答案要么根本没有用,要么非常复杂,我想添加我的:

The error means that Xcode can not find the file, whether it is in the project's folder or not.

该错误意味着 Xcode 无法找到该文件,无论它是否在项目文件夹中。

  • If you still need that image, what you can do is to open a Finderview and navigate to your project. Drag the file Xcode was complaining about into the project an uncheck 'Copy to folder'.

  • if you do not need the file anymore, on the left side of Xcode, find the file, it will be shown in red, simply tap on it and then delete/ backspace

  • 如果您仍然需要该图像,您可以做的是打开Finder视图并导航到您的项目。将 Xcode 抱怨的文件拖到项目中,然后取消选中 'Copy to folder'

  • 如果您不再需要该文件,请在 Xcode 左侧找到该文件,它将显示为红色,只需点击它然后删除/退格

Hope that helps some people :)

希望能帮助一些人:)

回答by sabari vasagan

To solve the issue copy the Image name. Then Filter it (Build Phases -> Filter textfield). Finally I removed it.

要解决此问题,请复制图像名称。然后对其进行过滤(构建阶段 -> 过滤文本字段)。最后我删除了它。

回答by Aman Singh Bhandari

For those who are struggling with this error while building Cordova app. Please keep the following point in consideration as it may lead to this error.

对于那些在构建Cordova 应用程序时遇到此错误的人。请注意以下几点,因为它可能会导致此错误。

  • The images should be tagged as "resource-file" and not as "source-file" in plugin.xml of your Cordova plugin as the former includes the images in "Copy Bundle Resources" (under Build Phase) and the latter to "Compile Sources" of your equivalent xcode project of cordova app.
  • 图像应在 Cordova 插件的 plugin.xml 中标记为“资源文件”而不是“源文件”,因为前者包括“复制捆绑资源”(在构建阶段)中的图像,后者包括“编译您的cordova应用程序等效xcode项目的来源”。

回答by Michelle

If non of above answers can fix your problem, try look into Xcode project where you reference your image file, I happened to referenced twice to the same png file. Once I delete one the reference, it worked. The error went away. Good luck.

如果以上答案都不能解决您的问题,请尝试查看引用图像文件的 Xcode 项目,我碰巧两次引用了同一个 png 文件。一旦我删除了一个参考,它就起作用了。错误消失了。祝你好运。

回答by Govind Wadhwa

It also happens when you have multiple images with the same name in TARGET->Build Phases->Copy Bundle Resources. To resolve it -

当您在 TARGET->Build Phases-> Copy Bundle Resources 中有多个同名图像时,也会发生这种情况。要解决它 -

Search for the image name that you are getting an error for in Build Phases search bar at the top. If you get multiple results in Copy Bundle Resources for the search query, just remove others from it by clicking on "-" sign. Make sure you have same images for the multiple results. If not you have to rename the actual files of other entries.

在顶部的构建阶段搜索栏中搜索您遇到错误的图像名称。如果您在搜索查询的复制捆绑资源中获得多个结果,只需通过单击“-”号从其中删除其他结果。确保多个结果具有相同的图像。如果不是,您必须重命名其他条目的实际文件。

clean cmd+option+shift+k and Build Project... work well for me....

清洁 cmd+option+shift+k 和 Build Project... 对我来说效果很好....

回答by ostap_holub

I have the same issue with resources. The problem was that I have copied target from another one and just forget to uncheck checkbox at target membership window.

我对资源有同样的问题。问题是我从另一个复制了目标,只是忘记取消选中目标成员资格窗口中的复选框。