XCode编译:pngcrush caught libpng error原因及解决方法

作者: iOS 发布时间: 2021-01-11 浏览: 1332 次 编辑

发现Xcode添加完图片资源后编译时出现如下提示错误。

While reading /Volumes/data2/project/XXXX/XXXX/bg.png pngcrush caught libpng error:
Could not find file: /Users/xxx/Library/Developer/Xcode/DerivedData/xxxx/Build/Products/Debug-iphoneos/xxx.app/bg.png
Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/xxx/bin/copypng emitted errors but did not return a nonzero exit code to indicate failure

原因:

该文件不是真正的png文件,可能是个jpg文件,实际的文件头信息是不一样的,造成不能识别。

解决方法有两种:

1、重新把图片文件处理成png文件
2、修改文件名后缀,比如改成.jpg