Loading iOS app resources from a website - ios

I'm currently working on an universal iOS application which has reached more than 100mb in size due to the heavy usage of video and sound files. I've implemented a solution for loading these assets at runtime (from a website) but I'd like to know if Apple approves of such actions.
The way it works now is this:
A bundle (with all the video and sound files) is created for each iOS device type: iPhone, iPhone Retina and iPad.
Then this bundle is zipped and uploaded to the server.
Depending on what device the app is installed on, the corresponding zip file is downloaded, saved to the Documents directory and then unzipped.
Finally the bundle is loaded with [NSBundle bundleWithPath: ]
This method works fine but I couldn't figure out by reading the docs if Apple may reject the app because of it? Thanks!

As long you are just moving around audio and video files, Apple won't have a problem.
But I would suggest (for the user's sake) breaking up the package a bit further so that the user doesn't have to suffer a 100MB download.
Perhaps include a few files so that users w/o internet can do something with your app.

Related

Settings-Watch.bundle desynced between iPhone and Watch [duplicate]

I've been pulling my hair out over this problem for two days now. I generate a small movie file in the iPhone App that I want to send from the iPhone to play on an Apple Watch. As I proof of concept, I put a similar .mov in the Bundle of the Apple Watch App and was able to play it with no problems. So I figured, easy peasy, now when I want to send a new little clip to the watch, I will just put it in an App Group Shared container and access it from there instead of from the Bundle. Nope!
I have been through tons of S.O. posts, tried many different approaches and nothing works as expected.
Before you ask, I have re-done the App Group several times, deleted the old ones from iTunes Connect, re-generated provisioning profiles, cleaned the targets numerous times, deleted the DerivedData several times, deleted the apps and started over several times and tried virtually every little tweak and fix I could find on S.O. Nothing helps.
I do think I know what the problem is, but have no idea how to conquer it.
Here is the code that I use in both the iPhone App and the Watch App to get a path to the shared container (this snippet if from the Watch side):
let fileManager = FileManager.default
let sharedContainer = fileManager
.containerURL(
forSecurityApplicationGroupIdentifier: "group.com.mycompany.myappname")
let dirPath = sharedContainer?.path
sharedFilePathOnWatch = (dirPath! as NSString).appendingPathComponent("watchPreview.mov")
print ("Shared File Path on Watch: \(sharedFilePathOnWatch)")
print ("Shared File Path from iPhone: \(sharedFilePath)")
The print statements show me the Shared file path that I send over to the watch from the iPhone (via Watch Connectivity) and the Shared Path that the Watch App resolves.
What I get when this runs it the following:
Shared File Path on Watch: /private/var/mobile/Containers/Shared/AppGroup/94AA7797-528D-4E96-9623-23285BE0742B/watchPreview.mov
Shared File Path from iPhone: /private/var/mobile/Containers/Shared/AppGroup/4D43C314-CCBD-4861-BF90-69A8AC71198C/watchPreview.mov
Now I was expecting that there would be only one shared container and that both the iPhone and the Watch should resolve the same path, but this is not the case. I've also noticed that these paths remain constant for the two apps over multiple runs. It's not a dynamic address that is changing every time I run as I suspected for awhile.
As a last ditch attempt to get this to function, I figured that since I had a path to the shared container on the iPhone and the shared container on the Apple Watch, maybe I could just move the file from one to the other because, well, they are supposed to be sharing. But no, even that doesn't work.
So the big questions are:
Why do I resolve two different paths on the shared Apps
How the heck do I get my little movie file from the iPhone to the Apple Watch
With the introduction of watchOS2 and native watchOS apps, Apple Watch apps are no longer just extensions of their iOS counterpart and hence they don't share AppGroups.
You cannot use AppGroups for sharing data from watchOS2 onwards. You have to use the WatchConnectivity framework for sending data between your iOS and watchOS apps.
See the Keeping your WatchOS content up-to-date page for more information on the topic.

Where is the file saved by Cordova File plugin on iOS

I am writing a PDF file on an iPhone running iOS 11, using Cordova File Plugin (in Ionic). The file is created successfully (e.g. in a location like file:///var/mobile/Containers/Data/Application/CDFC4E19-082F-4878-9168-F4A735CDAFEB/Documents or file:///var/mobile/Containers/Data/Application/DA918690-B345-438A-B26D-2EA21D618341/Library/Cloud), but then I can't find the file on the iPhone. I have tried setting the directory to cordova.file.documentsDirectory as well as cordova.file.syncedDataDirectory. When I run the Files app on the iPhone, it shows no recent documents, nor any documents at all. I can't find the file on the phone to view it outside of my app.
Where do I have to save the file to make it findable outside of the app?
I think I've answered this myself. Viewing a PDF that an app created is just not a thing on iOS, as useful as that may be. You can of course do that on Android, which is far more useful. It appears that to view the PDF, you have to use iTunes on an iMac to download the file from the phone. Jumping through those Apple hoops, which I am slowly becoming accustomed to, I was able to view the file in the cordova.file.documentsDirectory location.

IOS - Storing Audio and Videos outside App Sandbox

I am fairly new to IOS App Development. I have an app which plays audio and videos that are present in the App Package. Now I want my app to play audios and videos that are outside the App Package altogether i.e. if I uninstall my app the media files should not be deleted.
I have heard that all the apps can access media files that are added through ITunes. So I want to know the path of this folder(Kindly excuse me if you find my terminology vague. As I said I am fairly new to IOS App Development).
You cannot store the files outside app sandbox. Where as we can save image/video files to photos app
using, UIImageWriteToSavedPhotosAlbum/UISaveVideoAtPathToSavedPhotosAlbum
Please check developer documentation

Where does iPad app store data?

I have an iPad app that downloads PDF and audio files. I though these might be in the .ipa file (I used this thread ipad - extract images from application?) but I didn't see anything there.
Is there some way to find where these might be stored on a Mac (after syncing)?
Normally in many apps the media files will be downloaded to documents directory of app, which is inside the sandbox for the app. Simply telling when you instal a app OS will create a sand box, and all the data will be inside this sand box and only that particular app will have access to this data. So you will not be able to copy data.
Hope this answers your question.
The IPA is an application only. Once it is installed on your iPad, it becomes a "package". It does contain the data within that package with some apps that store locally. There is no Apple supported way to get to this data directly. Think of it like this. The IPA is kind of like a blueprint for a program. Like a blueprint for a shelf, I could build the shelf but the books wouldn't be stored in the blueprint. Only the shelf. When you install the app, the iPad builds your "shelf".

Releasing IOS app with files in Library directory

I have an app that is going to display a list of local video files. The app will only have a couple of video files at first, but that number will grow with future updates and in-app purchases. I would like to store all these videos in 1 place and it makes sense to put them in the app's Library directory so they are not user-accessible. Is it possible to publish an app with files already in the app's Library directory? Or do I have to put them in the app's bundle and then copy them to the Library directory when the app is first launched? Although that would result in the 2 videos files being duplicated since I can't remove them from the bundle.
Yes, you do need to copy the files from the app bundle into the Library if you want to treat all the videos in the same way. You cannot change the contents of the app bundle from inside your app and the only files your app has when it first launches are those that are in the app bundle.
If you really wanted (and if the video files don't change), you could make special cases in your code to be able to get the starting videos from the app bundle and the in-app purchase downloaded videos from the Library directory. But, unless the video files are quite large this seems a bit excessive.
A third option would be to have the user download the starter files on first app launch, but that may be suboptimal for other reasons.
Please look at my answer in this thread. It might concern you or at least be interesting to read.
Does updating iOS apps delete library directory files?

Resources