使用 Xcode 4 构建应用程序 - 它总是显示有关 PNG 图像的一些错误

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

Build app with Xcode 4 - it always show some error about PNG image

xcodexcode4

提问by Michael Chen

When I build my app with Xcode 4 it always show this error message:

当我使用 Xcode 4 构建我的应用程序时,它总是显示以下错误消息:

CopyPNGFile /Users/michaelchen/Library/Developer/Xcode/DerivedData/iMusicBox-boeawugacmhacbdtyymnprzfobyq/ArchiveIntermediates/iMusicBox/InstallationBuildProductsLocation/Applications/iMusicBox.app/list_cell.png Images/list_cell.png
    cd /Volumes/WORK/Works/iMusicBox
    setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS Build System Support.xcplugin/Contents/Resources/copypng" -compress "" /Volumes/WORK/Works/iMusicBox/Images/list_cell.png /Users/michaelchen/Library/Developer/Xcode/DerivedData/iMusicBox-boeawugacmhacbdtyymnprzfobyq/ArchiveIntermediates/iMusicBox/InstallationBuildProductsLocation/Applications/iMusicBox.app/list_cell.png

While checking alphas in /Volumes/WORK/Works/iMusicBox/Images/list_cell.png pngcrush caught libpng error: Not enough image data

在 /Volumes/WORK/Works/iMusicBox/Images/list_cell.png 检查 alpha 时,pngcrush 捕获 libpng 错误:图像数据不足

but It's OK with Xcode 3.2 - why?

但是 Xcode 3.2 没问题 - 为什么?

回答by Eva Madrazo

Found it!!

找到了!!

You have to save your PNG files as NOT INTERLACED. Try to open the file in photoshop (or similar), save as, and select "Not interlaced".

您必须将 PNG 文件保存为NOT INTERLACED。尝试在 photoshop(或类似软件)中打开文件,另存为,然后选择“不隔行扫描”。

It is working in my case

它在我的情况下有效

hope this helps

希望这可以帮助

回答by banane

That happens when you have multiple entries for the image file in your project file. I have no idea why but I just removed all entries, reloaded the project and added the file again.

当您的项目文件中有多个图像文件条目时,就会发生这种情况。我不知道为什么,但我只是删除了所有条目,重新加载了项目并再次添加了文件。

回答by Yohann T.

Check that you don't have duplicate entries in the Target's "Build Phase"-> "Copy Bundle Resources"

检查您在目标的“构建阶段”->“复制捆绑资源”中没有重复条目

回答by sunset

It may be the "Compress PNG Files" setting (from the Packaging section of Build Settings).

它可能是“压缩 PNG 文件”设置(来自构建设置的打包部分)。

I solved this error by switching it to "No".

我通过将其切换为“否”解决了这个错误。

回答by jaime

In my case I discovered my corrupted png wouldn't open in photoshop. I opened in preview, saved as psd, and then saved again from photoshop (save-as -> png -> not-interlaced). Compiles fine now in xcode 4.

就我而言,我发现我损坏的 png 无法在 photoshop 中打开。我在预览中打开,另存为 psd,然后从 Photoshop 中再次保存(另存为 -> png -> 非隔行扫描)。现在可以在 xcode 4 中正常编译。

回答by Resty

Try to find and resave this *.PNG files using "Preview", to be exact: File- Export...- "save as PNG". It seems to me, that it happens when you saving image in Photoshop with mode "Save for Web" and after this image will be saved with special compressing (LZW). That's all, good luck!

尝试使用"Preview"查找并重新保存此 *.PNG 文件,准确地说:File- Export...- "save as PNG"。在我看来,当您在 Photoshop 中以“Save for Web”模式保存图像时会发生这种情况,此后该图像将使用特殊压缩 (LZW)进行保存。就这些,祝你好运!

回答by inox

In my case I solved the problem by removing the blank "space-key" in folder/filename.

在我的情况下,我通过删除文件夹/文件名中的空白“空格键”解决了这个问题。

Hope this works for somebody too.

希望这也适用于某人。

回答by Codo

It looks like your PNG file list_cell.pngis corrupt. Xcode 4 makes more checks than Xcode 3 in many areas and reveals problems that have been lurking in your project all the time.

看起来您的 PNG 文件list_cell.png已损坏。Xcode 4 在许多方面进行了比 Xcode 3 更多的检查,并揭示了一直潜伏在您的项目中的问题。

Have you tried to open your PNG file in an image editor and save it again?

您是否尝试过在图像编辑器中打开 PNG 文件并再次保存?

回答by hofo

Mine weren't interlaced but I kept getting odd errors from pngcrush. Eventually I deleted the files not just disk but through XCode. I added them back in one by one by drang-and-drop into XCode, building after each, expecting to hit one that had an issue. I never did. My conclusion is that you really need to manipulate the files from XCode and not the filesystem at all.

我的没有隔行扫描,但我不断从 pngcrush 中收到奇怪的错误。最终,我不仅删除了磁盘文件,还通过 XCode 删除了这些文件。我通过拖放到 XCode 中的方式将它们一个一个地添加回去,在每个之后构建,希望找到有问题的一个。我从没干过。我的结论是,您确实需要操作来自 XCode 的文件,而根本不需要操作文件系统。

回答by Balázs Csordás

in my case with xcode 4.5 the problem is solved by permission giving with terminal

在我使用 xcode 4.5 的情况下,问题是通过终端授予权限解决的

chmod -R +rw /yourprojectpath/yourprojectfolder

chmod -R +rw /yourprojectpath/yourprojectfolder

this is maybe not the best solution because of locking files with file sharing. But will do if you are in hurry.

由于通过文件共享锁定文件,这可能不是最佳解决方案。但是如果你赶时间会做。