不是PNG filCommand copypng发出错误,但没有返回非零退出代码来指示失败

在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 

我的答案:

我有这个问题。 两个目标被添加为相同的图像。 转到项目目标 – >构build阶段 – >复制束资源并search您的图像文件名称

最有可能有两个条目。 删除一个。

通过这样做,我得到了解决我的问题。这对我的作品:) 🙂

乐于帮助 :) :)

情况1:格式不同

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

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

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

它会将你的图像转换为.png,并将创build一个包含转换图像的pngs文件夹。

情况2:两个同名的图像或一个图像添加两次:

正如Rajneesh071&Himanshu所build议的:可以有两个或更多同名的图像或两个目标被添加为相同的图像。 转到项目目标 – >构build阶段 – >复制束资源并search您的图像文件名称。 并删除重复的文件。

我希望给@ Rajneesh071的评论更多的可见性。 在我的情况下,我的项目中有多个Default.png文件。 当我第一次创build我的项目,Xcode把Default.png(和其他启animation面PNG文件)在我的项目。 创build我自己的启animation面,并通过Xcode添加到项目中,我开始得到奇怪的PNG粉碎错误。 在尝试了许多不同的答案之后,我发现了Rajneesh071的评论:存在多个Default.png。 在Default上做了一个快速filter,Xcode提供了与我自己一起列出的Default文件。 删除Xcode提供的默认* .png文件,并没有更多的pngcrush错误。

如果您觉得这个有用,请提高Rajeneesh071对原始问题的评论。