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.
-
1Tip:Be sure to put them in an asset catalog, since this may reduce the size only the images appropriate for the target device will be packaged in the IPA in IOS9 – Ryan Heitner Sep 11 '15 at 08:37
-
@RyanHeitner APK is an Android term, I think you meant IPA :) – Steve Wilford Sep 11 '15 at 08:38
-
hey, just include pictures as zip archive and unpack it on first run - fast and easy – sage444 Sep 11 '15 at 08:43
-
I wouldn't recommend what @sage444 is suggesting as it will prevent App Thinning from taking place in iOS 9. The App Store compresses your app anyway so this would have little effect (and this applies to any iOS version). – Steve Wilford Sep 11 '15 at 08:45
2 Answers
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.

- 1
- 1

- 8,894
- 5
- 42
- 66
-
Thanks for your answer @SteveWilford. I believe I've read somewhere that it was also possible to store the image's address so that the program could go through the image array faster instead of the actual image. But I might be mistaken as this could also only be the case for creating CoreData. In any case I will put it in a asset catalog and see how quickly images can be displayed in a tableView. – SecondLemon Sep 11 '15 at 09:09
-
1@SecondLemon Loading images from an asset catalog will be very fast as they are keyed by name. If you have an image in your catalog named "mainBackground" it is loaded into a `UIImage` using `[UIImage imageNamed:@"mainBackground"];` – Steve Wilford Sep 11 '15 at 09:13
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.

- 3,880
- 28
- 28
-
Thank you for the suggestion @Nicolas. I will certainly look into this! – SecondLemon Sep 11 '15 at 09:10