iOS: Include the resource(audio) files into the application folder of the app rather than adding into the bundle - ios

Currently my resource(audio) files is included in the bundle. Due to this user is unable to delete the unwanted audio files to save the disk space on his phone. Please let me know how can I directly include the audio files into the Applications folder of app while submitting the build to AppStore and not in the bundle. Thereby user can delete the files which are not of his interest and re-download from the cloud backup hosted on S3 if needed.

The only way to accomplish this is to NOT have the audio files included in the initial app install.
Instead, your app could download the audio files from a hosting service... either download them all on first launch, or download each file as-needed.
You would then store the files on the device so they don't need to be downloaded again... and you could provide a UI to delete files the user no longer wants stored locally.

Related

No such file or directory but file exists Xcode

I have audio files in my app.
I can listen to any of them but I can't run the app. Xcode writes " No such file or directory".
Here are the error and file paths.
I have tried to delete Xcode/Derived Data, but it doesn't work and in Copy Bundle Resources there are not red files.
iOS apps can access resources which are bundled into its Bundle during archive or the one that exists within its SandBox (resources downloaded programmatically and kept in document/temp folder of sandBox). Your audio files are on Desktop of your Mac and iOS app cant access them.
What should I do?
Select the entry of these items in your Xcode, delete them (remove only reference not original file)
now go back to desktop, select items and drag it to your project and select copy items if needed while copying
this will copy items to your app bundle now you can access it :)
Free of cost Advice
Thats a horrible coding approach to copy audio files (Assuming audio files are huge in size as I don't have context of your audio file sizes) to your app bundle :| this will bulk up your app size, think of more scalable approach, like downloading it on the fly from servers (lazy download, background download, or if you are streaming the m3U8 format etc etc)

Having a bit of trouble with copying a local file on iOS

Having only worked with Android/web dev before I am having a hard time figuring out where in the world my file should be getting copied to in iOS. After reading the file browser documentation on the iOS developer resource page it says that each app is an "island" which contains its own folder system. If I want to have my user be able to copy a file from my app's sdk to their iOS device, where should I put it?
I downloaded a file browser app from the app store on my iOS testing device but am I right in thinking that there is no global file browsing system?
I am using a Cordova plugin called Asset2sd which works perfectly for me in Android, getting the root storage folder and downloading the file to there. It has no iOS alternative so I'm going to have to figure something else out, I just need to know where to start. Do I have to have the user access my app's internal files somehow? Can I create a folder for them to look in when they download my app? Some documentation or something would be wonderful. I am totally lost.
Thanks!
You're right. Apps don't have access to the global file system. Each app only has access to their own app directory. Here's in-depth information on Sandboxing: https://developer.apple.com/app-sandboxing/
In your app's sandbox, you basically can manage files as you want, i.e. download, copy, move, delete, etc. So you can create a folder Downloads in your apps documents directory and then display the contents of this folder for instance in a table view.
Related documentation/links:
https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/index.html
https://stackoverflow.com/a/6907432/967327
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/iPhoneAppProgrammingGuide.pdf

iOS application cannot access downloaded file when relaunched - UUID changes

I've been debugging a problem where my app successfully downloads a file and copies it to the Documents directory. Lately the app cannot open the downloaded file on subsequent launches of the app. I've been printing out file URLs and this is what I see when the file is initially downloaded and opened:
unzipped /var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Documents/3.atcase to
/var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Library/Application Support/thebundleID/current-case
You can see the UUIDs are the same, but when I launch the app again I see this:
couldn't unzip /var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Documents/3.atcase to
/var/mobile/Containers/Data/Application/C18E7EFA-C0D0-4213-AF85-F5BC0D2A4207/Library/Application Support/thebundleID/current-case
This time the UUIDs appear to be different.
I will say tentatively that the answer is yes, the UUID used in the application container folder does seem to change every time the app is run, though I'd love to have some confirmation from a more experienced developer.
The solution to my problem was straightforward: Do not store absolute file URLs in the database. The URLs for the files are now constructed relative to the Documents directory URL every time the app is run. Since I name the files in a regular way, there is no need to store URLs anyway.

Store images in iOS app directory when install

I am writing an iOS app which download images from a backend server, and store them in the document directory. I know how it is done.
But I need to write a prototype first, which use some pre-given images (not retrieve from the backend server). My question is, is it possible to store images in the document directory during initial installation of the app? I don't want to hardcode them in the bundle directory.
Thanks
Nothing can be done when the app is installed, only when the app is run. The first time the app runs, you can either copy pre-bundled images to the other directory (Documents) or you can download them as needed. It sounds like you want the first option for the prototype.
Basically you need to do what you don't want to do - hardcode them in the bundle.
Remember, the app's sandbox is setup when the app is installed. This includes the creation of the Documents directory. But nothing is put there. Only your running app can store something somewhere in the app's sandbox.

upload file to folder on device, filesharing ios

im using filesharing in my app, working fine, but I want now for organization to be able to upload files from itunes to app folder
the itunes lets me import a file "Add", but i cannot drag the file to the created folder in my file system or "Add" in my folder,
so how can i upload the images to the specified folder in the device?
or do I have to dynamically check for the content of the /documents/ content and move the file to the wanted folder??
thanks
You can only add files via iTunes to the documents directory. You can either create your own AFP or WebDAV server on the iPhone and connect to it like a network drive (you have to code the server yourself). Alternatively you can check for new items in the documents directory as you suggested yourself and move them to wherever you want. Bear in mind that if you move them from the documents directory you will not be able to access them through iTunes once moved. Why don't you just store them in the documents directory anyway?

Resources