I have developed an application using Mac OS 10.7.5 and XCode 4.6.2. Application is working fine in my machine without any error/warnings.
But when I try to run in another machine Mac OS 10.8 and XCode 4.6.2, it shows pngcrush error for some of the images in that machine. Though there are few pngcrush errors, still application runs fine over simulator or device.
My question is: Why there is difference in debugging at both end and how to resolve it. (How to avoid such kind of errors)
Error Message
While reading ImagePath/ImageName.png pngcrush caught libpng error: Not a PNG file.
Pngcrush is an optimizer for PNG (Portable Network Graphics) files used by Xcode to compress PNG images contained in an app, with the aim of reducing the final size of the packet built.
This will be under below path
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
There must be two possibilities,
Your image is corrupted. Resave it as .png from photoshop or take new one.
Check whether you have added two/ multiple references in Xcode or not. If yes, then delete old references.
The images that are "not a PNG file" have probably been already run through Apple's private Xcode SDK version of pngcrush, which produces "optimized" files that are no longer valid PNG files.
Look at the beginning of a file that throws the error and see if the bytes beginning at byte 12 are "CgBI" instead of "IHDR". If so, you'll need to reverse the changes. Search SO for "pngcrush" and "CgBI" to find out how.
Related
Are there good tools for checking PNG files for issues that can be how I have ended up here? At first i feared with was an issue with the many thousands of "tiles" in my learning app (at 3 resolutions), but it seems one or more specific png files have an internal issue.
pngcheck works well and is a good resource. In addition, an OS-X app (in the app store) called "Quick Opaque" easily stripped out the (unneeded) alpha channel data from my png file, which cured the IDAT problem.
I am in the process of updating Hungry Helga (iPhone and iPad versions) for iOS 6, and all of the PNG files in my new app bundle archives are between 20 and 40 percent larger than they were in my past releases. Of course, this is putting me over the 3G download limit of 50 MB so I'd really like to figure out what's going on.
I am currently using version 4.5 of Xcode on OSX 10.7.5. If I recall correctly the previous version was built with Xcode 4.2. I tried turning on and off PNG compression in the build settings but that had no effect on the image sizes in the bundle.
To give a concrete example, my largest PNG image is 1.9 MB as a source asset. It is 2.1 MB in the old app bundle, and 2.5 MB in the new app bundle.
Did Apple change the way the PNG compressor works or is there maybe a setting that I'm missing or something?
I do not work for Apple nor do I have any inside information - however, I did poke around and have some theories. If you use terminal you can cd into the Xcode.app and find pngcrush there:
$ find . -name pngcrush
./Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush
If you then run:
./pngcrush -?
you find some interesting tidbits:
| It was compiled with LLVM 4.2.1 Compatible Apple Clang 4.0
(tags/Apple/clang-420.0.12) and modified by Apple as indicated in the
sources.
and
-iphone (optimize for iPhone OS)
Since I too saw that some large pngs where also much larger in the bundle than the original (which I had previously crushed myself!), I wanted to see how Xcode uses pngcrush. I used an old UNIX trick:
move pngcrush to xpngcrush
create a new executable shell file that calls pngcrush with the same argument list
log the arguments into a text file in /tmp
What I found was that Apple calls pngcrush as:
pngcrush -q -iphone oldFile newFile
One can infer from this that this Apple specific feature of pngrush was designed specifically to tailor the image for iOS. I say tailor, not crush.
Does Apple really care if your png is the smallest possible file, to save the greatest amount of space? I'd argue, not really - the devices have fairly large file storage space. Do they really care if your app downloads really fast? Again, I'd argue not really, since the user is going to assume the time is related to the size of the app, and that that is under the control of the developers.
However, what the user is going to hold Apple accountable for is the launch speed. From the first tap to when the app starts doing something - people will believe that is all the speed of the device (which we developers know is not strictly true). With the new iPad3, some of the launch images are now really big, so what can be done to make loading them as fast as possible?
I don't know the answer to that question, but I can imagine that Apple decompresses the original image, then re-compresses it with settings that make loading it in the device as fast as possible.
PS:
1) I just disabled the crush option, and observed Xcode 4.5 copying my png files without modification.
2) To get your app size down, have you tried using JPEGs with a high quality setting - even 1? Such images will look very good and be much much smaller. Virtually all images in my app are JPEGs. You can experiment with Preview to do the conversions.
EDIT: it occurred to me there may be an elegant solution to this. That is, for really important images - ones that you want to appear as fast as possible - then use pngcrush with the '-iphone' flag. For others, use more standard pngcrush options.
One way to do this is to create a new image directory, and write a shell file that pre-processes every png with a real crusher or tje '-iphone' flag, putting the output in the original image folder (where Xcode can get them). Then turn off the automatic 'Crush PNG Files' option.
EDIT2: I entered a bug at bugreporter.apple.com and posted on the Xcode listserv - if you have an interest in this bookmark the question and come back when its updated.
EDIT3: someone gave me a link that explains in more detail the how and why of Apple's '-iphone' option ImageOptim
EDIT4: Apple responded to my bug report, confirming that they modify the images for easier processing by iOS, which may make them larger, by intent.
Xcode 5 now got changes in image compressions. the best and compressed way is to use asset catalogs.
If even using Xcode 5 and asset catalogs doesn't result well for your app, check the other relative post PNG optimization issue using pngcrush tool for more answers could be helpful
Using David H's script, I found that Xcode is also passing the command line parameter "-f 0" to pngcrush. The man page indicates that the "-f 0" will disable any IDAT filtering before compression which can result in a larger PNG file. Testing on my 1.9 MB example file from above confirms:
pngcrush -iphone in.png out.png gives the 2.1 MB result that I am looking for
pngcrush -iphone -f 0 in.png out.png yields the undesired 2.5 MB result
Now the questions are: Why did Apple change this? Will it break image loading in some way if I work around it? If not, is there a setting for this in Xcode or will I always have to use a script to filter out the "-f 0" argument?
I'm baffled by how Xcode is managing to compress my iOS app so effectively. All of my images and sound files combined add up to 282 MB for about 3000 items. However, the .app is somehow only 126 MB! Further, the file sizes inside the .app package contents are the same, yet the folder sizes are all roughly half size. How is this possible?
The main reason is probably that all your images (assuming images make up the majority of the 282 MBs in your app) are compressed using pngcrush as a build step in your application. You can actually watch this by looking at at the build log from xcode.
The special version of pngcrush that is used in the iOS SDK cause the PNG images to be non-standard (making them unviewable on the Mac or any other standard program for that matter). Instead, they are adapted to the display hardware of the iOS devices which means that they will load faster as well.
I'm new to Blackberry development and have come across something I don't understand.
I have an application that I have been working on it supports Blackberry OS 5 to 7.1 and works on them all apart from OS 6. For some strange reason I get:
Error starting Foo: Class 'net.rim.device.api.system.WLANListener' not found
on Blackberry OS 6 only! There is no OS specific code (as far as I know). This is after I have cleaned both code and Simulator (using Eclipse) and signed the code. Most of the time the application refuses to install on the OS 6 device - of course, it works perfectly fine on other OS versions. What could be causing this?
I’ve finally discovered the problem after a lot of research and trial and error.
If the application is over 64kb in size rapc the Blackberry compiler splits the file into multiple files called sibling COD’s. The COD file that you see in the deliverables folder is actually a zip file containing the main COD file and all its siblings. They should all be 64kb or smaller although I have still seen the when first COD file is larger.
The fix is to make sure that you have no files in your project larger than 64kb. I had images that were larger although I have read that someone had a class that when compiled came to greater than 64kb causing issues, so they split the class up and solved the problem that they were having.
The symptoms were strange, I was getting an inconsistent compilation for different OS versions resulting in different strange issues for different devices, I was thinking at the time that it seemed like a linking issue, it seems like I wasn’t too far off. Thank you.
I can't manage to download the last version of the DirectX SDK (june 2010) : http://www.microsoft.com/downloads/details.aspx?FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba&displaylang=en
When I try to install it by double clicking the DXSDK_June10.exe I get the following message:
DirectX SDK error http://erytmo.dubbing-brothers.com/download/directxsdkerror.png
It seems that the file is corrupted. Is there another way to download this SDK?
Check the file size of what you downloaded. You probably just need to re-download it.
I just ran into this problem, then I looked at my file size, and it was only 300MB instead of 500+MB, so somehow the download had been interrupted.
I download DirectX from my home and transfer it it was no problem to install it. It seems the firewall of my company corrupt the download: the good file was 599 452 800 bytes versus 599373885 bytes for the bad one.
Their server is to slow. So typical for Microsoft!
1) Copy DXSDK_June10.exe file to "C:\" .
2) Run DXSDK_June10.exe .
That's all.