iPad: PNG Crush error
Asked Answered
A

15

74

I am trying port my iPad project to latest iPad 2. I installed iOS 4.3 SDK with Xcode 4.0. When i try to build my project, i'm getting the following error. I don't know why am i getting this error. Could someone help me to resolve this build error?

While reading /Users/username/Desktop/iPAD/MyProject/trunk/Resourses/images/top_bar.png pngcrush caught libpng error: Not a PNG file..

Could not find file: /Users/username/Library/Developer/Xcode/DerivedData/Project-fmhveawksgdtnraclfizuhrekmzi/Build/Products/Debug-iphoneos/MyApp-Upgraded.app/top_bar.png

Autogenesis answered 22/3, 2011 at 6:37 Comment(2)
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: 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.Also seeCorsica
I faced a similar problem and posted a solution that worked for me here. It also happens when you have multiple images with the same name in your project and copy resource to bundles.Ingrain
C
60

Did you check whether the file Users/kavapanga/Desktop/iPAD/ALN II 3 latest 2/trunk/Resourses/images/CS_logo_for_top_bar.png exists? Also check if it is infact a PNG file. Right click on the file and do a Get Info to check if the file has any other extension and is marked as hide extension. If you are not sure of the format of the file, opening the file and save it as a PNG file again should work ,most of the time.

Cockoftherock answered 22/3, 2011 at 6:42 Comment(10)
Hi Krishna, Yes, i see the file is available with the .png format.Autogenesis
Could you please try saving it as a PNG once again?Cockoftherock
Hi Krishna, As you said, i saved again as .PNG format. It is not giving build error now. But, when i try to install on my iPad 2 through Xcode 4(all the settings are done), it shows "Finished Running MyApp-iPad" , but i'm not seeing the app installed on my iPad. What could be reason?Autogenesis
That will be difficult to answer without knowing a lot of details about your app. Did you look at the logs in the console as the app runs? Also, can you run it in debug mode with break point?Cockoftherock
Ok. Now i am just trying to run in iPad 4.3 Simulator, it builds completely and finally stuck at "Attaching to MyApp-iPad" for long time..Any idea?Autogenesis
Not sure. May be you could close this and post this as a new question to get more eyes on it.Cockoftherock
No problems. I am able to install by changing it to proper target as "Release". Thanks for your help!Autogenesis
I think it just got upvoted but not accepted. Not sure why. Did you click on the tick mark against the answer?Cockoftherock
Just did it, please check. Btw, i have one more question, how do i debug the project into iPad 2. I tried choosing Debug target and then tried installing the app, but it installed but then Xcode quits with this error "Error starting Executable MyApp-iPad" "Error launching remote program: failed to get the task for process 462." Any idea on this? Sorry for querying all in this same question itself.Autogenesis
I have not tried on an iPad 2. Is it a physical iPad or the simulator? Again I suggest moving it to a separate question so that more people can look at it and help in quick resolution. You can post the link to the question here.Cockoftherock
D
89

I had the same problem, but it wasn't because of a corrupted png : it was because two PNG files had the same filename in different directories of my source tree. What was peculiar was that the errors (I had 4 files which had "twins") were not identical from one build to another. On one run I had errors on all files, on the other only on some of them.

Dug answered 26/5, 2012 at 13:47 Comment(2)
This happened to me. I opened a project I hadn't been using for a couple of days, and after two or three builds, this. Weird...Gaffrigged
Possibly both versions were added to your copy-files build phase; at least that was the problem for me.Kedgeree
C
60

Did you check whether the file Users/kavapanga/Desktop/iPAD/ALN II 3 latest 2/trunk/Resourses/images/CS_logo_for_top_bar.png exists? Also check if it is infact a PNG file. Right click on the file and do a Get Info to check if the file has any other extension and is marked as hide extension. If you are not sure of the format of the file, opening the file and save it as a PNG file again should work ,most of the time.

Cockoftherock answered 22/3, 2011 at 6:42 Comment(10)
Hi Krishna, Yes, i see the file is available with the .png format.Autogenesis
Could you please try saving it as a PNG once again?Cockoftherock
Hi Krishna, As you said, i saved again as .PNG format. It is not giving build error now. But, when i try to install on my iPad 2 through Xcode 4(all the settings are done), it shows "Finished Running MyApp-iPad" , but i'm not seeing the app installed on my iPad. What could be reason?Autogenesis
That will be difficult to answer without knowing a lot of details about your app. Did you look at the logs in the console as the app runs? Also, can you run it in debug mode with break point?Cockoftherock
Ok. Now i am just trying to run in iPad 4.3 Simulator, it builds completely and finally stuck at "Attaching to MyApp-iPad" for long time..Any idea?Autogenesis
Not sure. May be you could close this and post this as a new question to get more eyes on it.Cockoftherock
No problems. I am able to install by changing it to proper target as "Release". Thanks for your help!Autogenesis
I think it just got upvoted but not accepted. Not sure why. Did you click on the tick mark against the answer?Cockoftherock
Just did it, please check. Btw, i have one more question, how do i debug the project into iPad 2. I tried choosing Debug target and then tried installing the app, but it installed but then Xcode quits with this error "Error starting Executable MyApp-iPad" "Error launching remote program: failed to get the task for process 462." Any idea on this? Sorry for querying all in this same question itself.Autogenesis
I have not tried on an iPad 2. Is it a physical iPad or the simulator? Again I suggest moving it to a separate question so that more people can look at it and help in quick resolution. You can post the link to the question here.Cockoftherock
J
52

I had the same problem. How to fix : Open up image with Preview -> File > Export > Format change to PNG and you are done !!

Janelljanella answered 12/4, 2012 at 17:49 Comment(2)
This was a great find. Artist had saved as psd but with png extensionSynge
plus, need to clean the project. :DMisgiving
E
10

There is no issues with image or Xcode. The issue, which creating that image from photoshop, is whether that image is interlaced or not interlaced. While saving your image in photoshop you will get one option for that.

Check out this link for more info:

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

not interlaced: You should use image which is not interlaced. This is the original png image.

interlaced: This option is suitable for the image which are getting downloaded from web. Specifically saying, this is used when you require to reduce image load time. What this option internally does is, it will create a .png file but with lower clarity and lower dpi like a normal jpeg image. That's why such images are having property that it is jpeg image.

Hope this will help you all.

Enjoy Coding :)

Estradiol answered 27/4, 2012 at 4:28 Comment(0)
K
10

I got this error when I moved images around in the project's folder, to an "Images" folder.

Turns out my "Copy Resources" build phase contained the steps both to copy the files from their new, correct folder - and from the previous folder where they were stored. Removing the outdated build steps fixed the errors.

Kabyle answered 22/6, 2012 at 14:51 Comment(0)
E
6

Another reason pngcrush considers PNG files to not really be PNG files is if you accidentally export them with layers intact. If you inspect the file in Finder, look around the More Info area (Dimensions, Color Space, etc.) for an item called "Layers"

It might say something like:

Layer 68, Title Banner, Group 26

This happens when designers sometimes Save As PNG instead of exporting for web/mobile. And it completely destroys libpng (and thus pngcrush).

The fix is to properly export the PNG, or open the PNG yourself and re-export it as a "flat" PNG.

Eudora answered 12/2, 2013 at 20:9 Comment(1)
Note: this can also be caused by PSD files that are saved with a PNG extension, but are really PSD files. This happens fairly often too, no matter how good the designer. Late nights are late nights. :)Eudora
A
6

This can be caused by incompatible PNG file format. You will need the "Color profile" for your png file to make it work in Xcode.

First off, check the info for your file.

enter image description here

While this is a valid PNG file, this is NOT the format that Xcode can take. You will need the following PNG format:

enter image description here

To convert your PNG file to a format that Xcode can take. You can use Preview to export the file.

Artieartifact answered 22/11, 2015 at 11:29 Comment(2)
I had edited some of the graphical assets on Linux using gwenview and GIMP, saved as PNG then hit this error/ For me THIS answer and solution is perfect. Clearly the original assets by our UI team were done on a Mac and were (obviously) perfect as far as Xcode was concerned.Joppa
my Map Tile overlays were done on a Mac, without the Alpha Channel ( hence no sRGB ) but still fails in my project, yet work perfectly in others.Maris
B
3

Had this issue as well. The PNG existed and wasn't corrupt.

Solved it by:

  1. R-click the image in xcode, select "Delete"
  2. Remove reference only (don't actually trash the file)
  3. Drag n' drop it back into xcode (in-place) making sure you select the correct targets
Bingle answered 13/3, 2013 at 20:1 Comment(1)
Worked for me except I added the files back in not drag and dropUnaware
U
2

I had this problem and found there was a problem with the png. I remade it and worked fine.

Unschooled answered 24/12, 2011 at 14:7 Comment(1)
Yes, same case happened with meAltimetry
N
2

I had the same problem. Even though the file extension may be png the file may still be something else. And 'get info' shows what ever the file extension is I think. Open up the file in preview and go to tools -> show inspector -> File tab. Here you should be able to see the actual file type.

Noguchi answered 7/3, 2012 at 10:23 Comment(3)
Have you got the reason behind this issue? We have got images created from Adobe Photoshop, saved as .png. But those images are being displayed as JPEG in that menu, which you have suggested. Not getting why?Estradiol
I think if that menu shows them as JPEG then they must be JPEG. Maybe there was some mistake while saving them. Did you try doing this with some PNG downloaded from web.Noguchi
Every once in a while I save a .psd with .png extension... Damn Photoshop defaults!Gaffrigged
E
2

I had this error and it was actually totally unrelated to the png's it was erroring on. The actual problem was I had two files with the same name in my project (I had drag'n'dropped a newer version of a 3rd party class assuming it would replace the older version).

I removed the reference to the duplicate file and that solved the build errors.

Exieexigency answered 29/1, 2014 at 17:22 Comment(0)
O
0

Problem Solved

I got the same problem couple of time in development but today i found that there are two solutions and their possibilities, here is this

Problem Solved#1: If you Create or your designer create the design which they saved the pnd from adobe illustrator then its got the problem if you create by yourself just copy all the AI artwork to the photoshop or if your designer create it then just tell them to import the illustrator format to the photoshop and send the pnd.

Problem Solved#2: select the image right click the image->get Info and check that it is in correct .png format or not if its not then just edit .png extension.

Just Enjoy.

Outport answered 1/12, 2012 at 23:32 Comment(0)
R
0

I get the same error when I tried to copy my project folder and run the project. The project in the original folder didn't have that problem.

Deleting the copy and making a new copy of the folder solved my problem.

Runaway answered 15/5, 2013 at 12:17 Comment(0)
O
0

Error:

While reading /Volumes/Mac OS/RDC/Workpot/RestApp/RestApp/default1024_768.png pngcrush caught libpng error: Not a PNG file..

Solution:

  1. I opened "default1024_768" file in PaintBrush tool and saveAs PNG file with same name.
  2. Replaced the Icon file in Xcode project --> Clean --> Build.

That's All its work like charm

Hope this will help someone.

Orcein answered 9/1, 2015 at 6:5 Comment(0)
T
-3

I have this bug quite often. if you 100% sure that your png is there and is correct then just simply recompile the project, if does not work - recompile again and again, and sometimes it will start working ;-) that's a bug in Xcode that was there for long time (since Xcode3).

Turbosupercharger answered 17/5, 2013 at 15:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.