I have made a very simple iPhone app with Xcode 6.1 and swift. I am really new to ios developing and ran into an app which in the end is 134 mb! of course this is not acceptable.
I have background images for all screen sizes which add up to 20 mb. and thats it! I am storing those images in xcassets, as thats the preferred way I guess.
the app shouldnt have more than 25 mbs, I think.
I figured out that I had some references doubled in my project. I removed these and still my .app file is 89 mbs!
What am I doing wrong? I read several threads on this, but nothing really helped!
What I did until now:
- reduce the size of all pngs
- disable the compress PNG option, as it seems to make the PNGs bigger (lol)
- configured the build settings to run the fastest and smallest build
- Strip Debug Symbols During Copy build setting to Yes (COPY_PHASE_STRIP = YES)
edit1: Apparenty Xcode does something weird with my pngs. Some of those pictures, that are 2 mb originally, are more than 10mb in the .app-file. What does xcode do there ?
It is actually not surprising that the Apple recompressed files are bigger. They are optimized for fast load not small size. If you do not care about size over speed, defiantly do turn off the compression. Even if you do care about speed you can do better than Apple.
https://imageoptim.com/xcode.html
So yes, turn off the PNG compression. The first thing I would do is build the ipa. An ipa is actually a zip file so build the ipa, copy it to a folder on your mac, rename the file with a .zip extension and double click on it. This will expanded it. Find the app in the Payload folder and right mouse click on it and choose show package contents. You will see all the assets. Sort by size. I am guessing you have overly large images. At that size my guess is that the extra size is likely to be caused almost entirely by the PNG files.
Consider using non retina images for some. Honestly most people wont notice. iOS will gracefully use the non retina on retina. This can save a ton of space,
Also consider using jpeg files instead of PNG for some of the files if you do not need transparency. Jpeg files are less efficient but can be much smaller. Compare both. Depends on the extent to which the images are continuous tone.
By default PNG file are 32 bit. 24 bit color and 8 buit alpha/transparency. You can save a bit of size by going to 24 bit. You can also save a lot of size going to 16 bit color or below. At 8 bit PNG files use a color lookup table. Play with Photoshop and the save for we options at PNG with bit depth 8 and below.
I have all sorts of expensive compressing software but often use the $8
https://itunes.apple.com/us/app/lossless-photo-squeezer/id704083918?mt=12
Try the 8 bit PNG option and the JPEG options.
EDIT
I did some research. I had always know Fireworks did better PNG compression. I did not realize that there was an 8bit PNG with an 8 Bit alpha channel. Photoshop supports 8 bit with a 1 bit Alpha Channel. I have always told people to use 32 bit PNG if their transparency needed more than 1 bit. In the future I will let them know the 8 bit with 8 bit alpha may be the better route, They just can use Photoshop for the final save of the file. They just need to save a 32 bit and compress elsewhere.
http://calendar.perfplanet.com/2010/png-that-works/
David
Related
I have an app, that is made with unity 2d. Exporting it to android it weighs 100MB. Exporting it to iOS weighs 1.2GB (ipa is 104MB), but inside iTunes weighs 1.2GB, which is too much.
We tried to reduce the texture size, but then, images get very pixelated on the device.
Any ideas on how to fix this?
Here is what the .ipa uncompressed shows what is getting all the MB:
sharedassets4.assets (just that file, gets 342 MB)
iTunes shows the installation size, so if you unzip your ipa file, you will get those 1.2GB. The install size on Android could also that big. Did you check that?
Usually this happens when you compressed your texture in True Color or 16 bits and the zip compression works really well i.e. on textures that have a lot of pixels with the same colors.
Possible Solutions
1) if your textures don’t require transparency, you could switch to compressed Textures (PVRTC on iOS and ETC on Android). But if the require transparency, you should not switch to compressed because transparent PVRTC can look very ugly and ETC does not support alpha.
2) I don’t know if it is possible in your project, but you could try to reduce the amount of texture by using tint or slicing them.
UPDATE 1
I currently having a similar situation and as it turns out.
--------------------------------------------
| Platform Android iOS |
|--------------------------------------------|
| APK/IPA 380MB 400 MB |
| unzipped APK/IPA 1.19 GB 1.13 GB |
| install size on device 380MB 1.15 GB |
--------------------------------------------
The difference is that iOS unzips the IPA file completely on installation and
Android contrary reads during runtime directly out of the APK, so you could argue, that is not really installed, but it is definitely another installation type.
Check your texture import options. You may have different options set for Android import and iOS import.
iOS import is usually PVRTC, which prefers textures which are a power of two in size and square (256x256, 512x512, etc).
It sounds to me like you might have iOS set to a non-compressed format.
Did you compress your meshes? Also strip bit code. Another thing I found helpful is flattening your textures, and removing layers. Also changing the indexed color count to a lower amount. For 1024x1024 it can get to 170KB, if you tweak it right.
Also remove normal maps, and change your shaders. It won't look as granular, but it'll reduce the size. You may want to offload the textures to an Assets Server, too and get textures at runtime as opposed to preloading them in your bundled assets.
My app requires that each user has a profile picture of around 140*140px. Right now I am using jpgs, I am wondering if performance wise it will be better to use pngs. I read pngs are good for small UI elements and images, jpg for large images with detail such as photos. Obviously my profile pics are photos but they are small. Would it make much difference switching to png? Thanks
JPEG is best for small file sizes of photos, even for low resolutions.
PNG makes sense when there are many pixels of the exact same color next to each other. This is not the case with photos.
These should be helpful for you.
When to use PNG or JPG in iPhone development?
PNG vs. GIF vs. JPEG vs. SVG - When best to use?
Apple optimizes PNG images that are included in your iPhone app bundle. In fact, the iPhone uses a special encoding in which the color bytes are optimized for the hardware. XCode handles this special encoding for you when you build your project. So, you do see additional benefits to using PNG's on an iPhone other than their size consideration. For this reason it is definitely recommended to use PNG's for any images that appear as part of the interface (in a table view, labels, etc).
As for displaying a full screen image such as a photograph you may still reap benefits with PNG's since they are non-lossy and the visual quality should be better than a JPG not to mention resource usage with decoding the image. You may need to decrease the quality of your JPG's in order to see a real benefit in file size but then you are displaying non-optimal images.
File size is certainly a factor but there are other considerations at play as well when choosing an image format.
I am using xcode 6.0.1 and after setting all App Icons and Default Images my app size is jumped by 13 MB.
My App support iOS 5.1.1 and Later. Using Vector image don't support iOS 5.1.1 and iOS 6.x, I am not sure what i can do to reduce the build size.
Check list that might help you
->The first step is to look at your .app bundle and see what files inside it are taking up the most space.Before trying any optimizations, you should measure. This will tell you what to focus on improving.
->Use 8-bit Images Where Possible
Using an 8-bit PNG format where applicable can decrease your image size by a factor of 4 in comparison with 32-bit images. 8-bit images support a maximum of 256 different colors, so they should only be used images which use a small set of colors.
->Use High Compression for 32 bit Images Where Possible
Using Adobe Photoshop’s “Save For Web” feature can reduce the size of JPEG and PNG images considerably. By default, .png images will be compressed with pngcrush by Xcode automatically when the app is built.
->Check Your App, Usually apps contain extra files, like headers or a readme, that are never used.Be sure that you aren’t including any resources that aren’t used in your current project.
->Make sure dead code (code which is defined but never called) is stripped. Check that build setting DEAD_CODE_STRIPPING=YES.(Under your target build settings, then under "Linking" there is an option for "Dead Code Stripping". It defaults to yes for projects created with Xcode.
)
->What type of sounds files are you using? .caf files are incredibly large. As a general rule, you should compress audio using AAC or MP3, and experiment with a reduced bitrate. Quite often a 44.1khz sample is overkill and a lower-bitrate clip won't have a perceptible drop in quality.
->If you do not need to support iOS devices running all iOS versions.Specifying architecture/s to which the binary is TARGETED. This eliminates other architectures and reduces some size.
->Strip the binary of debugging and internal symbols (build settings STRIP_LINKED_PRODUCT=YES, STRIP_STYLE=all, DEPLOYMENT_POSTPROCESSING = YES).
->"Slender" tool will let you know the unused graphics in your app.
http://itunes.apple.com/us/app/slender/id493656257?mt=12
P.S. Before you make changes refer below source once.
Source:https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html
and https://developer.apple.com/library/ios/qa/qa1795/_index.html#//apple_ref/doc/uid/DTS40014195-CH1-MEASURE
I observed that when we drag and drop images in Assets folder, the system creates copy of them if you specified the image set to be Device Specific. E.g: If you specified an image "A" for iPhone and same image for iPad (individually), the system will maintain two copies of "A" rather pointing to one same image. In this way the size keeps on increasing because of duplicate images. Check for that also.
images.xcassets size is depends on the image size.Try to reduce the image size if you want to reduce the app size.You can un Zip the ipa file and check which component have larger size.Try to use png images instead of jpeg if used.
I have an iPhone app that overlays an image over a view created by a XIB, using CIFilter CIHardLightBlendMode. The view is 1000x1000 pixels, and I want to maintain that size until the end. This makes the image files about 1 MB as a png, if there is any complexity.
I've tried using JPGs, but it doesn't overlay the image onto the view on a device (it works on the simulator). I've tried compressing the PNGs, but they get garbled when they get overlaid over the view (they look identical to the full quality ones until they are overlaid). Also, when XCode re-compresses the PNGs to the special iOS version, the compression size savings are lost.
I really would like to compress the files somewhat, but I'm not sure what will work with CIFilter. Any tips?
Thanks to this article - Clever PNG Optimization Techniques - I found a trick that reduced the file size.
Posterization reduced the file size from 1.3 MB to 458 KB (and 326 KB after XCode optimization!). This is a huge savings. My photos (textures) can be heavily posterized, so I'm not sure that this will work quite as well in other situations.
If you are interested in a new approach that reduces compressed image file size, I have created and iOS framework that compresses PNG images into a more compact form called PNGSquared. It is somewhat like the posterization approach, but you have more control over quality.
I want to reduce compiled file size of ios ipa file.
I get "How to reduce" way: How to reduce the size of my iPhone application?
But I want to know "How to analyze" way:
My image is
$ du /path/to/app
100 /path/to/app/images
150 /path/to/app/sounds
And I wan to reduce file size on effective point. Visualization is more good!:
http://www.lomont.org/Software/Utilities/DiskInfo/DiskInfo.png
I know I should delete files which is not used but is linked project...
I have used a tool called [ImageOptim] (http://imageoptim.com/xcode.html)
It incorporates a number of tools inside which crush your png files significantly (in my case it was between 25% to 50%) and had reduced the size of my app of around 0.6 mb
One thing to remember is to disable Xcode's PNG optimization.
There is no magic way to reduce the file size of ipa file.
What you can do to reduce the size are just as you said,
Remove any unnecessary files
If you have a lot of images, consider using PNGCRUSH to reduce file size of images
If you have a lot of sound files, consider using compressed audio file such as MP3, also, consider changing to mono instead of stereo. Bit rates of around 96K is still pretty decent.