iOS application size - How to reduce or download more after - iphone

I am after some suggestions on how to reduce the final app size that gets submitted to apple?
Or is there any way to have stuff download after the app is isntalled? so that we can keep the app under 20 meg, but then the app downloads the rest of the program after the user has installed it and run the application?
ta
Daz

If your application uses a lot of image resources, your application could download those images instead of building them into the application.

Theoretically possible. Your app can access the file system, so it can make and save, and later read files.
The deal-breaker I see is that for most purposes, Apple probably wouldn't allow it.
They test the program as-is when you submit it, and they'll notice that it just sits there and tries to download a bunch of stuff from your server. If this takes more than, say, 30 seconds, they'll reject it for usability problems.
If the content downloaded could have been bundled with the program, they'll probably have a problem with that. If you could argue that the downloaded content changes rapidly and is a feature of your app, it might fly, but only if you keep it small..

Sure this is totally possible. Since it is most likely some sort of media that is causing a large file size, either images, video, or audio, you could definitely download them after the fact or supply a download button for users to add these features as "extra" content, if they are not critical to the operation of your app.
One thing to consider is that some users are not on an unlimited data plan. So for politeness, they should know what you are doing.
Also, if you are just over the limit, you might also be able to ship the application with the resources in a zip archive and then decompress the archive in the Documents directory.

In many applications images take lion share of the download size, and they can be greatly reduced with ImageAlpha and ImageOptim.
Check out this case study halving download size of Tweetbot by converting images to a more efficient PNG variant.

Related

Is there a path every app can write files in the jailbreak iPhone?

I should hook UIResponder of every app, including SpringBoard and any others. In the hooking, I will write something to the specified file. If I set the path to /var/mobile/Library/MyApp, recommended by Cydia, I found that only the SpringBoard and MyApp could write successfully.
So is there a place every app can write and read?
I admit that I'm not 100% sure on this one, but my guess would be no, there is not a path that every app can writes files to on a jailbroken iPhone.
Certainly, jailbreak apps (installed in /Applications/) on a jailbroken phone can write to locations that can be shared between those jailbreak apps. But, as I understand your question, you would like to inject code into normal, App Store apps, so that those apps can also read and write to the shared location. That part I don't think is possible, because jailbreaking does not completely disable the sandbox for 3rd-party apps installed normally, under /var/mobile/Applications/.
Now, there might be a workaround. There are some shared folders that are accessible to all apps for certain purposes. For example, any app can write images to the saved photos album. What you could try is to take the content of the file you want to write, and encode it as fake image data, in a UIImage (e.g. with [UIImage imageWithData:]). You'd probably need to add a valid image header to the data. Then, you save the file to the photos album, using something like
writeImageToSavedPhotosAlbum:orientation:completionBlock:.
Another app could then find the fake photo by enumerating the saved photos album, and then converting the asset back to image representation to pull the real data back out.
However, this seems quite complicated, and possibly wouldn't work (I haven't tried it). Perhaps you could tell us why you want this shared file. Maybe there's a better way to share the data, without using a globally-accessible file?
Notifications can help you with this. Every app will send interprocess notifications about the events. You could start a daemon that will listen for this notifications and save them in a file. Or you could listen for them in SpringBoard as he can write, for example, to /var/mobile/Media. Depends on what you want to do with this file. Check out my answer here How to create a global environment variable that can be accessed by SpringBoard or other applications in the jailbroken iPhone?

Need to make a DLC "packet" system for my iOS game

I'm developing a game for iOS and I need to make a system to download "packs" after the player bought them with In App Purchases.
I've search on the internet for a method like using a bundle, or just using web services, but I really don't know which one is the best.
Let me be specific: in one pack the player has between 1-3 sprites, 1-2 music files, and 1-3 backgrounds.
So what I need to do is download that "pack" and store it as "purchased". What methods would be the most reusable and modular?
By far the easiest and most simple solution would be to bundle the DLC in to your app with an update and simply use an in app purchase to unlock them for the user. This saves their time and bandwidth as they no longer have to download the files and it saves you paying for a server to host it all.
There are several ways to go about this. In the past I created a system for a previous client that used a manifest that referenced all the files in the "pack", then downloaded each asset. The manifest could be updated to point to updated/different assets if needed, and contained a version number so that the system would know if it needed to update assets after the user had previously downloaded the pack. I probably wouldn't worry so much with a one-size-fits-all approach on this; just get something up and running for this one project that can be used on all DLC packs. Your next project will probably need heavy modifications for the same system to work.

manifest file download size limit

I am learning to use Manifest files and had this question. What if some website created a manifest file that will make me cache files for, say, 3MB. 3MB is a lot for my IPhone when I run on 3G. So some vicious website can create such manifest file and make me use up all my data allowance?
Another question is that, as a responsible developer, is there anyway to detect if a user is using 3G or not so I can serve a smaller manifest file in the former case?
Thank you
Your question is tagged 'iPhone' so I am going to give an iOS-specific answer.
The offline storage, which holds the files linked to in your manifest, seems to be limited to 5MB. Evidence for this is all circumstantial, as the limit is not mentioned in Apple docs. However, some Apple engineers have conceded that there is a limit. The newest versions of Mobile Safari, in some circumstances, offer to allow the user to expand the storage, but you, as a developer, cannot force them to do so.
5MB is not really that much, and many users will certainly notice that something is going on, and if they don't want it to happen, simply close the tab. I understand that not every country has the same limits, but most users in the US are limited to 2GB/month. At this rate, an unsuspecting user would have to accidentally re-download your manifest, and the files it lists 100 times to use up just 25% of their bandwidth allotment. It's a fairly low limit, and the possibility of maliciously using up someone's data allotment is fairly remote.
As far as how to tell if a user is on 3G or WiFi, check out the Reachability example in the Apple Developer Center. It does exactly that. There is no way to do it in a web app (as opposed to a native app) that I am aware of.
Is there a size limit for HTML5 Manifest? No.
No, iOS does not implement W3C network information API as oppose to Andorid Webkit.
I'm not sure how you're getting this manifest file, but if you're using NSURLConnection, it's simply a matter of keeping a running total of how much data you've downloaded (best place would be connection:didReceiveData:) and cancelling the connection if it gets above 3MB. Remember to zero that number each connection though.
As for finding the device, the specifics seem trickier than they should be, but I've found a pretty simple example of how to do it (source code n' all): Determine If iPod is First or Second Generation

minimum application size for my iphone application?

i am developing a application which contains many images which appear on different buttons click and has an mp3 file too..When i checked the size of my .app file it is around 6.8 mb which i think might be too large?? is there any way i can reduce the size of my .app file though i think reducing the size of my images(already around 15kb) wont be the solution.
6.8mb is fine and is small enough that people can downloaded it over 3G (the limit is 20Mb; you need wifi if it's more)
One thing to keep in mind is sales! On any app you do now or in the future you will want to keep the total size under 20mb.
Think about how many users want to "instinctively buy" your app. They saw a friend with your app and want to download it right then and there, but ohh wait... cant do it till ya get home! LOST SALE - More than likely that person will forget by the time they get home.
In your case 6.8mb is nothing compared to many apps that are games. I've seen 200 - 300mb apps that take a while to download on wifi. (WSOP Poker , Gamebox)
Good Luck my friend!

iPhone programming: How much data can I store in my app's Documents Directory (root folder)?

The reason I ask is my app lets users cache map tiles. Does anyone know the real cap on how much data I can let them store?
You can store as much as you want until you run out flash. Having said that, your users probably won't like it if you start eating all of the space on the phone.
Also, make sure you put it in the Cache folder, as opposed to Documents. The Documents folder gets backed up when you sync to iTunes, the Cache folder is not. If you have a ton of data in the Documents folder it will massively slow down iTunes synching.
About a year ago the word was there is a 2Gb limit on app size, but you'll be hard pressed to find an "official" declaration of such, even on apple's site or the discussion forums there
That being said 2Gb is pretty hearty for a mobile app, caching and all
I'm not aware of any quota for apps using the writable area, but it would be easy enough to check.