Does anyone know why Xcode (4.6.3) would start TiffUtil in the Copy Resources Phase instead of just copying PNG files to the bundle using CpResource . I'm now ending up with some normal PNG icons and splash screens and a few tiffs. I've checked the images, there doesn't seem to be anything wrong with them.
Thanks,
Daniel Dekkers
I ran into this last week!
The problem was in the build settings.
Combine High Resolution Artwork COMBINE_HIDPI_IMAGES
Combines image files at different resolutions into one multi-page TIFF
file that is HiDPI compliant for Mac OS X 10.7 and later. Only image
files in the same directory and with the same base name and extension
are combined. The file names must conform to the naming convention
used in HiDPI. [COMBINE_HIDPI_IMAGES]
It wants to take your x.png and x#2x.png and turn it into a multi-page TIFF. But since this option isn't valid for iOS, none of your images will work correctly.
So, in the build settings, try and find "Combine High Resolution Artwork" and turn it off. If its not in there, you can also search for the COMBINE_HIDPI_IMAGES flag and turn it off.
Related
So Ive raised a topic on this before because its something that has created a lot of confusion for me, and I'm sure it has for a lot of other users. Currently I have my Xcode project and my assets manager as comes supplied with every project created. by default an AppIcon already exists in here which looks a little like so...
You can see that this (the default) AppIcon has 3 types of icon that have to be loaded in. Currently I have 3 images:
a 87x87#3x
a 120x120#3x
and a 180x180#3x.
I have no idea what the extension means (the #3x bit) so it would be nice if someone wouldn't mind explaining that to me aswell. But back to the main problem I'm having...
I find that when I go to create a new AppIcon, although its not necessary as I could just replace the images in the old AppIcon that is created by default, it does have a different interface which looks as follows:
Now you should be able to see that the the "slots" in the new AppIcon are empty because I have absolutely no idea about what dimension images I am supposed to be supplying and to where they are supposed to go to within here. I also have no idea what extensions my images are supposed to be using and how many I am supposed to have. The whole process seems quite overwhelming and ridiculously complicated. I'm utterly confused as to why apple have made this so inefficient and just plain confusing :/
I have been looking at an icon generator which seems rather useful (as recommended in my last thread):
https://itunes.apple.com/us/app/asset-catalog-creator-app/id809625456?mt=12
and I have also had a look at this although it doesn't seem particularly helpful:
http://martiancraft.com/blog/2014/09/vector-images-xcode6/
I have mainly been looking at this however it doesn't seem to offer much help if I'm honest:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW2
So to sum things up...
What resolution images do I need for app icons?
Which AppIcon template am I using, the default or a newly created?
What extensions do my images need? ("#2x", "#3x" etc.)
What do the extensions mean/do?
Thanks anyways!
-Ryan
UPDATE 1!
I have kindly been provided a great link for a app icon generator which works online, it seems very quick and very reliable and anyone having the same issues, I would recommend you give this a try :)
IconMaker
Older question, but I use the following shell script to convert a PNG to the different icon sizes. Just make sure your input file is big enough. I use something like 2048x2048 so it can generate everything.
For the convert commandline tool, first install Homebrew: https://brew.sh/
Then install ImageMagick via:
$ brew install imagemagick
Adapt the orig and new_prefix variables if you wish, then run the script.
#!/bin/sh
orig="appicon.png"
new_prefix="appicon_"
iphone_settings="58 87"
iphone_spotlight="80 120"
iphone_app="120 180"
ipad_settings="29 58"
ipad_spotlight="40 80"
ipad_app="76 152"
ipad_pro_app="167"
iphone_ipad_notification="20 40 60"
app_store_icons="512 1024"
launch_icons="640x1136 640x960 320x480 1536x2008 768x1004"
for i in $iphone_settings $iphone_spotlight $iphone_app $ipad_settings $ipad_spotlight $ipad_app $ipad_pro_app $app_store_icons $iphone_ipad_notification; do
echo "Resizing to $i x $i"
convert -resize $i $orig ${new_prefix}${i}.png
done
#3x if for the new resolution on iPhone 6 Plus and iPhone 6s Plus.
#2x is for the normal retina resolution.
Its related to the resolution of the image. an image 40x40 needs 3 files:
image.png 40x40
image#2x.png 80x80
image#3x.png 120x120
this applies for all the images used in the app, not only the icon.
Have you tried this one? MakeAppIcon
Its excellent to generate the icons.
What would be the best way to include a lot of images in the bundle? I have an index of (game) items thus about 4000-5000 image files (total 27mb so not that big). Just include the whole map in the bundle or maybe first write a script that converts them to NSData? I could imagine there would be a smart way to do this so the app wouldn't have to look through all images individually to find a single one. Would love to hear your thoughts.
27mb isn't a huge amount to download so the easiest option would be to put them in an asset catalog, as Ryan Heitner mentioned in his comment this will allow App Thinning to take place in iOS 9.
I'm not sure what you mean by this:
I could imagine there would be a smart way to do this so the app wouldn't have to look through all images individually to find a single one
Each image will need to have a unique name (this is true regardless of the number of assets you have) and your code references the images by that name so it won't have to "look through all images individually to find a single one".
Alternatively if you really want to reduce the initial download size you could use On Demand Resources (another upcoming iOS 9 feature) to store them on Apple servers and loaded on demand in your code. Presumably you won't be targeting only iOS 9 though so in this case you would need to host the resources yourself and load them using standard techniques (see here, here, here, or use a library.
You should pack them in a texture atlas.
Then, the texture atlas files should be imported in your bundled via a folder reference (blue folder icon) and not a group (yellow folder icon).
Images imported in bundle in folder reference won't be optimized be Xcode on packaging. So you can make your own file optimization using imageOptim. It can compress a lot more than what Xcode can do on JPEG and PNG images.
I optimized and put compressed images into Images.xcassets
When I build the package and look into the contents of it, I see that all of the images are modified by XCode (build tools etc..) and for example Default-568h#2x.png (218KB) becomes LaunchImage-568h#2x.png(455KB)
This makes it impossible for me to put optimized images.
What am I doing wrong here?
Your issues is most likely premultiplied alpha channel. I ran into this same issue when designing my game engine and it was relatively painless to fix.
Last I knew there is no option to disable premultiplied alpha channels for the Xcode bundle.However, Xcode comes bundled with a textureool which can be used at build time to format your images into another format that does not suffer this same optimization. Since my code focuses on sending texture data to OpenGL i used the powerVR format PVRTC. However, you're free to utilizes whatever format you like.
If you decide to go this route you can add a build target to your project which converts all png files into which ever format you prefer.
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 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
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.
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.
I had the same problem.
How to fix : Open up image with Preview -> File > Export > Format change to PNG and you are done !!
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 :)
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.
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.
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.
While this is a valid PNG file, this is NOT the format that Xcode can take. You will need the following PNG format:
To convert your PNG file to a format that Xcode can take. You can use Preview to export the file.
Had this issue as well. The PNG existed and wasn't corrupt.
Solved it by:
R-click the image in xcode, select "Delete"
Remove reference only (don't actually trash the file)
Drag n' drop it back into xcode (in-place) making sure you select the correct targets
I had this problem and found there was a problem with the png. I remade it and worked fine.
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.
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.
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.
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.
Error:
While reading /Volumes/Mac OS/RDC/Workpot/RestApp/RestApp/default1024_768.png pngcrush caught
libpng error: Not a PNG file..
Solution:
I opened "default1024_768" file in PaintBrush tool and saveAs PNG file with same name.
Replaced the Icon file in Xcode project --> Clean --> Build.
That's All its work like charm
Hope this will help someone.
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).