ios 不是 PNG filCommand copypng 发出错误但未返回非零退出代码以指示失败

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

Not a PNG filCommand copypng emitted errors but did not return a nonzero exit code to indicate failure

iphoneiosipadios6default.png

提问by HDdeveloper

I am getting following error while adding images the running the project on iPad. It worked fine on simulator with all images but on iPad its running but showing no images.

在 iPad 上添加运行项目的图像时出现以下错误。它在带有所有图像的模拟器上运行良好,但在 iPad 上运行但不显示图像。

CopyPNGFile /Users/user/Library/Developer/Xcode/DerivedData/RImageGallery-cmwaittvclhwgxfpcoarddipyliv/Build/Products/Debug-iphoneos/RImageGallery.app/Default.png PhotoBrowserDemo/Default.png
    cd /Users/user/Desktop/Demo
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng -compress "" /Users/user/Desktop/Demo/PhotoBrowserDemo/Default.png /Users/user/Library/Developer/Xcode/DerivedData/RImageGallery-cmwaittvclhwgxfpcoarddipyliv/Build/Products/Debug-iphoneos/RImageGallery.app/Default.png

   Not a PNG filCommand /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




(null): While reading /Users/user/Desktop/Demo/PhotoBrowserDemo/Default.png pngcrush caught libpng error:




(null): Could not find file: /Users/user/Library/Developer/Xcode/DerivedData/RImageGallery-cmwaittvclhwgxfpcoarddipyliv/Build/Products/Debug-iphoneos/RImageGallery.app/Default.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

回答by Himanshu Agnihotri

MY ANSWER:

我的答案:

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 doing so I got resolved my problem.This works for me :) :)

通过这样做,我解决了我的问题。这对我有用:) :)

HAPPY TO HELP :) :)

很高兴能帮助你 :) :)

回答by HDdeveloper

Case 1: Format difference

案例1:格式差异

It worked when i changed the images from jpg to png, using Preview. Previously It might not be working due to .png as name only not as format. This linkhelped.

当我使用预览将图像从 jpg 更改为 png 时,它起作用了。以前它可能无法工作,因为 .png 作为名称而不是格式。这个链接有帮助。

Also to convert the multiple images to png in a folder in single step use terminal. Using cd goto the folder containing the images (JPGs or any type). run Code:

还可以在单​​步使用终端中将文件夹中的多个图像转换为 png。使用 cd 转到包含图像(JPG 或任何类型)的文件夹。运行代码:

mkdir pngs; sips -s format png *.* --out pngs

It will convert your images to .png and will create a pngs folder contain the converted images.

它会将您的图像转换为 .png 并创建一个包含转换后图像的 pngs 文件夹。

Case 2: Two images with same name or one image added twice:

案例 2:两张同名的图片或一张图片添加了两次:

As Rajneesh071 & Himanshu suggested: There can be two or more images with same name or two targets were added for same image. Goto project target ->Build Phases -> Copy Bundle Resources and search for your image file name. and remove the repeated file.

正如 Rajneesh071 和 Himanshu 建议的那样:可以有两个或多个同名的图像,或者为同一图像添加了两个目标。转到项目目标 -> 构建阶段 -> 复制捆绑资源并搜索您的图像文件名。并删除重复的文件。

回答by bobnoble

I'm hoping to give more visibility to @Rajneesh071's comment. In my case, there was more than one Default.png file in my project. When I first created my project, Xcode put Default.png (and other splash screen png files) in my project. After creating my own splash screen, and adding them to the project through Xcode, I started getting the weird png crush errors. After trying many different answers, I came across Rajneesh071's comment that more than one Default.png existed. Did a quick filter on Default and sure enough, the Xcode provided Default files where listed along with my own. Deleted the Xcode provided Default*.png files and no more pngcrush errors.

我希望让@Rajneesh071 的评论有更多的可见性。就我而言,我的项目中有不止一个 Default.png 文件。当我第一次创建我的项目时,Xcode 将 Default.png(和其他启动画面 png 文件)放在我的项目中。创建我自己的启动画面,并通过 Xcode 将它们添加到项目后,我开始收到奇怪的 png 粉碎错误。在尝试了许多不同的答案后,我发现 Rajneesh071 的评论说存在多个 Default.png。对默认进行了快速过滤,果然,Xcode 提供了默认文件,其中列出了我自己的文件。删除了 Xcode 提供的 Default*.png 文件,不再出现 pngcrush 错误。

If you find this useful, please give an uptick to Rajeneesh071's comment on the original question.

如果您觉得这有用,请给 Rajeneesh071 对原始问题的评论加分。