与 xcode 中的图像有关的奇怪错误,未分类,pngcrush 和复制 png 文件错误?

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

Weird error to do with images in xcode, uncategorised, pngcrush and copy png file error?

objective-cxcodepngcrush

提问by dev6546

(null): While reading /Users/lewiselliott/Desktop/Final Version/2bm/2bm/static.png pngcrush caught libpng error:
(null): Could not find file: /Users/lewiselliott/Desktop/Final Version/2bm/build/Debug-iphoneos/2bm.app/static.png
Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS Build System Support.xcplugin/Contents/Resources/copypng emitted errors but did not return a nonzero exit code to indicate failure

What does this mean and why has it only just started happening, how do I fix it?

这是什么意思,为什么它才刚刚开始发生,我该如何解决?

回答by Ram G.

I had this problem. Two targets were added for same image. Goto project target ->Build Phases -> Copy Bundle Resources and search for your image file name. Most likely there are two entries. Remove one.

我有这个问题。为同一图像添加了两个目标。转到项目目标 -> 构建阶段 -> 复制捆绑资源并搜索您的图像文件名。很可能有两个条目。去掉一个。

回答by Andrei Filip

I'm guessing that this happened when testing the application on a device. It is because of your image static.png. It isn't a png file. Remove that file and try again. Also, I'm guessing that the application doesn't crush and the above mentioned image is not showing anywhere where it should. Try opening the file in photoshop and save it as a png.

我猜这是在设备上测试应用程序时发生的。这是因为你的图像 static.png。它不是一个 png 文件。删除该文件并重试。另外,我猜应用程序不会崩溃,并且上面提到的图像没有显示在它应该显示的任何地方。尝试在 photoshop 中打开文件并将其另存为 png。

回答by robinappsonite

I had this problem too. Turned out I had two sets of png files with same name in two different groups. I deleted it all and loaded one set. Then it worked fine. My problem was with the Default.png files used for splash screen.

我也有这个问题。结果我在两个不同的组中有两组同名的 png 文件。我把它全部删除并加载了一组。然后它工作得很好。我的问题是用于初始屏幕的 Default.png 文件。

回答by Chahal

I had same problem. I checked all my targets and found that [email protected] was added only once([email protected] was the file which was causing problem for me). I simply unchecked 'compress PNG files' option in Project -> Target -> Build Settings -> Packaging -> Compress PNG Files and It did worked for me.

我有同样的问题。我检查了我所有的目标,发现 [email protected] 只添加了一次([email protected] 是给我造成问题的文件)。我只是在项目 -> 目标 -> 构建设置 -> 打包 -> 压缩 PNG 文件中取消选中“压缩 PNG 文件”选项,它确实对我有用。

回答by PWiggin

Had a similar issue. My problem was that I saved it as a jpg, but named it a png file. I don't think xcode liked that very much.

有一个类似的问题。我的问题是我将它保存为 jpg,但将其命名为 png 文件。我不认为 xcode 很喜欢那个。

回答by yair

I had a file with .pngextension that when I only changed the extension to .jpg- it didn't work. I couldn't really tell what image format it was supposedto be...

我有一个带有.png扩展名的文件,当我只将扩展名更改为时.jpg- 它不起作用。我真的不知道它应该是什么图像格式......

So I searched for an online image converter that would maybe "swallow" that corrupted piece of art and make a decent formatted image out of it and first search in Google gave me this.

因此,我搜索了一个在线图像转换器,它可能会“吞下”损坏的艺术品并从中制作出像样的格式化图像,并且在 Google 中的第一次搜索给了我这个.

It did the job well. After it was converted to JPEGI was able to open it with an online image editorand save it as PNG. That refreshed PNGworked like a charm.

它做得很好。它被转换后JPEG,我能够与打开它的在线图像编辑器并保存为PNG。那种精神焕发PNG就像一种魅力。