iOS On-Demand Resources - Download Only On Demand. Debuging - ios

I'm using on demand resources for several videos in my app. I have tagged the resources, and put them in the "download only on demand" tag, in the Targets Resource Tags. I download the resources using NSBundleResourceRequest, and it all works great. When I execute the code, the resources get downloaded, and I can see this in the disk section in xcode.
I don't think I need to post my code, for my question.
My question is, when I run the app from xcode on my device, I see that xcode runs the app, and copies the videos to the app right away, even before I execute the download code. Also, if I check my app in the settings, iPhone storage, I see the app is taking up a lot of space since the videos are already downloaded. Why are the videos already taking up storage before they are "downloaded"?
Is this happening only because I am debugging the app, but when I publish the app, the videos will only be downloaded when the user executes the download code?
It seems a basic question, but I cannot see anyone who address this point/
Thanks

Is this happening only because I am debugging the app, but when I publish the app, the videos will only be downloaded when the user executes the download code?
Yes. The Simulator is not a real device and Xcode is not a server. Your access to the resources is correctly simulated — they are nil until you ask to begin accessing them, and then they start working — so you are able to test, which is all that matters. But to get the real experience you should run thru TestFlight on a device. See https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/TestingPerformance.html for more about that.

Related

How to test Trivial Drive example on a phone

I need to put in-app payments into my app. There are two problem areas at present.
Get the TrivialDrive Example app so I can run it on my phone correctly and recompile and install it easily.
Discover the structure of the TrivialDrive app and pick the parts that are relevant to me.
any help is welcome
Using Android Studio 12.5 and Java
The key feature of testing in-app payments is that, although you need to publish the app in (at least Internal Testing) google Play, you can in fact side-load newer builds directly to your device. So it needs to exist in the Google Play app store but subsequent builds can be tested on your device without uploading it to Play.Google
https://docs.google.com/document/d/1oPHyYYWpcfTyXjideWhicAkd1R1N1OwSsPi1xHILFBM/edit?usp=sharing
This document explains straightforwardly the steps to get to debugging on your phone using logcat.

tvOS Difference Between TestFlight Installed App and Direct USB Run App on AppleTV Hardware

I am working to add a TopShelf implementation to my tvOS app. I am also working to create a Collection View implementation that has a similar functionality from within the app. Both work fine in the simulator on my Mac but don't work when deploying to my Apple TV using TestFlight. I tried using the USB-C cable to try to capture some logs or see what is going on when the UIActivityIndicator just spins. I thought it could be related to trying to download too many images or some other networking issue. I started caching the images and again that works well in the simulator but not on the device.
When I plugged into the device and ran the app it worked as it should, even with a higher number of downloads. I later updated the version via TestFlight and was back at the same position. Right now I am in a position where the app works every time with my own view controller and the TopShelf part, but does not work at all if deployed via TestFlight. I can't get any logs to figure out what is going on because when I connect the USB cable and run the app, it starts working.
Has anyone seen similar behavior or know of any way to troubleshoot what is going on?
I was able to determine there were a couple of things going on. The first was that the simulator was setup for a build configuration of debug. I went in to Edit Scheme and changed the Build Configuration for Run to "Release." This allowed me to recreate on the simulator what I was seeing on the device. It also made it a lot easier to debug as I could easily add logs to track down where the code was hanging.
The root of the problem was that I had a while loop doing nothing while I waited for a network block to update a flag. I've used this hack in other situations and have never run into a problem. If I added one NSLog command to the while loop it would flow through fine, but with nothing in the loop it just hung even though the network dispatch was done downloading data.
To fix this, I read up on using
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
which solved my problem (and I'm assuming made my code a lot more reliable too).

iOS deleting all app sandbox data automatically

I have a very strange issue that has been occurring to a few users of my app. One of the users actually described the issue to me.
My app downloads magazine data to the device to allow for offline reading. This means that users can sometimes have around 10 gigs+ downloaded to the device.
The problem this user experienced (and a few others have too) is that randomly all sandbox data gets deleted from the app (included core data files). The user told me that he was downloading something in a different app and got the "Storage Almost Full - You can manage your storage in Settings" popup message.
He went to the settings app and went to General > Usage. He then saw the app was using around 13 gigs of data. While he was in that list he said every time he went out of the Usage tab, then back in the app's data was getting smaller and smaller. Until eventually the app said it was using 0mb.
When he logged back into the app all his data was deleted and core data was also removed which lead the app to think he was a completely new user with no data downloaded.
I then ran some tests on my own where I made sure my device only had 100mb of space available. I then started downloading in the app. The warning message popped up alerting me I was running out of space and I ignored it and continued downloading. I have now downloaded about 1.5 gigs of data and am still downloading and the device seems like it is freeing up space somewhere else to make room for my downloads.
I've searched far and wide and have found no one else ever experiencing a problem like this. So my questions are:
Has anyone else every experienced this issue before?
Does Apple have a policy that will remove app data from the app that uses the most space if the device is running out of space?
Is there an algorythm that decides which app will get cleared when space is running out?
Is there a way to tell the OS not to remove data when running out of space?
Any help would be appreciated!
Assuming you're storing the data in the caches subdirectory:
On iOS 5.0 and later, the system may delete the Caches directory on
rare occasions when the system is very low on disk space. This will
never occur while an app is running. However, you should be aware that
iTunes restore is not necessarily the only condition under which the
Caches directory can be erased.
Documentation here

App Size and dynamically downloading resources

My application that will be posted soon is going to dynamically download images and resources that have to do with art when something is unlocked in the app. This will keep down on app size and the app will only download resources when it is needed. Very similarly to Droid development since they cap at 50mb sizes.
Does anyone know if this could potentially harm the approval process to apple? The expansions that will be downloaded could be around 30mb and could be very slow if the user decides to do this on data. Any advice or prior issues with apple on some type of process like this would be very helpful.
Thanks in advance.
You should be good. I have an app that downloads every new XKCD webcomic when it is released. Each being an image, this has added considerable size to the app.
To play it safe, I would suggest including something in the app description (within the app and on the iTunes store) that tells users the app dynamically downloads content. There is no rule against it, but letting the user know is always good.

images missing when uploaded to app store

I have an iOS app with a bunch of images in it. I used images inside of table view cells and as tab bar images. When testing for development and distribution everything worked just fine, and Apple approved it and put in on the app store. Problem is - I checked out my app from the app store and all of the images are gone! Both image sets are completely absent. Now, this only happens in the version of the app actually on the app store - the app in Xcode looks fine. Anyone have any idea what might be causing it?
Much appreciated!
p.s. if it helps to see the app yourself, let me know and I'll post a link.
Check your targets. In case if you use different target for building for appstore and for adhoc build you may included some of resources only into testing target.
Download your application from appstore, explore it using steps definehere, see if your images are in there, if not then re-upload binary with properly linked images, else, consider answer from #Nikita.

Resources