NSUserDefualts data is duplicated many times in the Preferences folder - ios

We are storing a xml config file which contains several key-value pairs in UserDefualts. The size of the .plist after the data is stored into the USerDefualts file is in between 5-50MB based on the user config file.
Recently in one of our beta devices, we found that the app Preferences folder is of size 5GB which is 500 times more than the app size.
I downloaded the app .xcappdata for the beta device and found that the folder
AppData/Library/Preferences is 4.98GB
We have no idea why that folder is huge.
Inside that folder there are 800 of files with name in the format
(bundle-identifer).plist.1ESwPpG
1ESwPpG is the random string at the end of files.
And the size of each file shows 0 bytes.
There are two more additional files in this folder.
One is the app .plist (35MB) file and other one is com.apple.EmojiCache.plist (4KB).
Why the folder is over 4.5GB ?
I can delete the app and reinstall it which would solve the problem, it would be useful for us to know the cause of the issue.
I couldn't find much from https://forums.developer.apple.com/thread/69830.
and iOS app's Documents and Data becomes huge
Note: This app on the beta device hasn't been removed from the last 2-3 months. The app in the device is upgraded with every beta build.
Note: Deleting these files does reduce the folder size, but the file is showing 0 bytes when looked at file inspector window. Also the file shows nothing when opened by any text editor.
I see that the userdefault data .plist which is 35MB of size is duplicated many times which increase the folder size.
I'm wondering when exactly this happens.

Related

Why is our app size increasing drastically with little change of function?

We have an app currently in the App Store, and its size is as follows according to iTunes connect:
iPhone 6: Download size 21.8MB, install size 28.5MB
Now this is not too bad. But with a newer version we have uploaded to iTunes connect, the sizes are like this:
iPhone 6: Download size 35.5MB, install size 73.1MB
And the original package compressed size is 114MB.
Now this is too large, even unacceptable. I have checked the .app file within the archive(which is 178MB), and surprisingly discovered that my code alone takes 55MB(which in debug mode is only 11MB), and swift standard libraries around 40MB.
The function of code of this version does not differ much with the previous: we added iPad support, added a few images(the asset is 7.8MB on both debug and release archive, which is not a problem), and updated our project to swift 3.
All the release sizes above are with whole module optimization turned on. Might there ba a configuration in my build settings that may leads to this huge size? If not, what else could I do to reduce the app's size as much as possible?(especially the 50MB codes)
Besides, WHAT is the cause of this? Is it swift 3 since we didn't change our code much?
We also face such kind of issue in our previous app. At that time we make below steps to check which part of application is taking more space.
1) Copy Final IPA file which was generated by Archive.
2) Rename "application.ipa" to "application.zip"
3) Unzip application.zip file.
4) Open unzip folder and find "application.app" file in "Payload" folder.
5) Right click on "application.app" file and select "Show Package Contents".
6) After click on that you will see the list of all the files added in your final application bundle.
From that file listing you can see which file is taking lager space and act accordingly.
Assets.car : it's for image assets added in your application.
Frameworks : all frameworks list which are added by you in your code.
file_name.nib : This file is for your xibs added in your project.
file_name.storyboardc : This file is for your Storyborad added in
your project.
Apart from that their will list of font, images, videos, bundles,
etc. files.
From these step you can get an idea that is the cause of build size.

Are there any apps to see what makes an iPhone app size large?

My iPhone app has recently got a little larger than I'd like (nearing 100MB) and I'm not entirely sure what the cause of it is.
There are many apps for the Mac like DaisyDisk that let you see the make up of your Mac's storage, but is there something where I can see what's taking up so much space in, say, a .ipa file?
Bryan's answer is the way to go. Unzip your IPA (Rename it from .ipa to .zip), find the .app file in the unzipped folder, option click the .app file and view contents, press command J and check "calculate all file sizes", and then sort the results by file size. More than likely you have big media files in your app.
If you try this with iMovie, for example, you'll find the the largest folder in the app is called "Assets", and it's 261 MB.

Size of Xcode Project .ipa is WAY too big (1.6 GB)

I recently finished an app on Xcode and compressed it to a .zip file (or .ipa as I changed the ending later). However, I was shocked to see that the size of the .zip was 1.62 GB, which is incredibly large for an iOS app, and way too large to be accepted by iTunes Connect.
After looking over similar questions on Stack Overflow, I proceeded to remove all resources in my project to see if they were the cause of the problem. I took out any .PNG or .JPG image file, and also removed any .MP3 audio file. However, after compressing my app it was still at an absurd number - 1.56 GB!
I don't know what to do now, as I really need to submit this app but it is still way too big. I would appreciate any help on this issue. Thanks!
Edit: I had to create a completely new project in order to fix this issue, as I couldn't find what was making the size so big in the original project. I copied and pasted the storyboard, added all the image and audio files, and re-created the classes by copying and pasting the code.

Why my iOS App's Documents directory became a file?

We are developing an iOS app with Enterprise distribution.
It ran well in hundreds of devices, but we found some iOS 6.1.3 devices failed to launch it hours later the first run, because the App's Documents directory became a file !
Our App did nothing special except it was downloading about 80MB MP4 files from a remote HTTP server.
I assumed that something wrong when it operated the Documents directory, but so far have little clue to identify what's 'dangerous' usage in our codes.
Did you have encountered similar problems? How did you fix it?
Thanks a lot to anybody kindly helping to figure it out.
What I suggest doing is for your app to test for this when it launches, and if there is a file there, move it to some other place (like the temp folder), then create the Documents directory, then move the file back into that directory with the same name (or change the name). That will at least prevent your app from stalling.
If you have any means of remote logging, you could bin hex the first 64 bytes of the file and send it to your service for analysis (if you know what's in the file it should help you figure out who created it.)

Shipping zip with thousands of audio files within app bundle

I am developing app for studying foreign languages, and I'll need to ship 80000 little audio files in my app.
To reduce the size of my app I decided to ship only part of them in the bundle, on the zip archive, and then un-archive it to documents directory. Then, when iPhone will be in Wi-Fi network, I'll little by little download all the others.
But the problem is that Apple says, that we are not allowed to store big files in the Documents Directory. Flagging files for not backing up works only since 5.0.1
So I see two ways for me:
Ship all the files without zipping them and storing them in the app bundle – but that's too huge.
Ship a zip, un-archive it to the cache directory and then check, if they are (not deleted by system), and download one, if it's removed.
What should I choose or is there any other way for me to work it out?
Zipping audio files isn't a good way. I'm sure that saved space will not play any role.
Best solution is to use AAC encoded audiofiles.
Choose suitable quality between 64-128 kbps. And probably mono.
iPhones 3Gs and higher have hardware support for this codec.
There isn't much point in zipping files in the app bundle if you will just decompress them to the documents directory. When app bundles are delivered to iOS devices from the app store they are zipped up anyway (.ipa file), so unzipping to documents will make your app actually take up much more space on the user's device (once in the app bundle and once in the documents directory).
Automated way:
If you want to download them without using too much documents space you can write a predictive cache which has a maximum allowed size. You can keep track of when each file was last accessed and when you need to download a new file remove the oldest-accessed files until you have enough space. Your app can predict which files are needed next based on progression through the lessons, but even if they access a not-present file you can download it just-in-time and add it to the cache for future re-use.
Manual way:
You could provide a user interface to show the user how much space the different lessons are using and split it into lesson packs. Allow the user to control which packs remain cached and show how much space they use. They can decide when to download new packs as they progress through the lessons and when to remove old ones (if they want to save space). If the user wants to keep the files locally then you should let them, even though it uses lots of documents space.

Resources