Is it possible to provide userfiles within an .IPA? - ios

I have an IPA that I want to distribute to users. The IPA includes some user data that should be moved to the documents directory on the first install.
My problem is that I can copy the files from the resources directory but not delete it, meaning that the data will be twice on the device.
Is there a possibility to include data into an IPA that is put into the documents folder on install? Or is there any folder I can add to an IPA that I can access with write permissions without having the device jailbroken?
I have taken a look at the documentation but could not find anything about that topic.

You can't do that.
I believe you are overthinking it. If the amount of data is small than there won't be any problem with it being twice on the device.
If the amount of data is big, you should put it on a server and download it after installation.

No, this is not possible. All data with in the application bundle is readonly and can therefor not be modified.

Related

Providing default population to "Library/Application support" folder

I'm writing an iOS app which needs a ~60MB resource file to work correctly. I would like to provide this file with the app itself, so it can work straight after installing it from the store without downloading extra data at the first launch.
I also want to be able to update such file by downloading a new version of it from a specific URL. I thought the most appropriate folder to store this file would be "Library/Application support", as specified in the guidelines provided by Apple itself.
My problem is that I can't find a way to provide the "Library/Application support" folder with a default population using xcode 9. I don't want to have multiple copies of this file around to avoid wasting space, and I want the possibility to update this file to a newer version, overwriting / replacing the old one.
This might be a newbie question (I'm a newbie of iOS development) but I really couldn't find anything related to pre-populating that folder.
You cannot delete anything from your distribution bundle. It's just not allowed.
So you options are:
Distribute the resource with the app, and create a copy in "Library/Application support".
Don't include the resource with the app, and download it on first run.
You didn't say what the resource is, so I don't know if this would be an option, but... Include only a portion of the resource with the app, copy it into "Library/Application support" and "update it" on first run.

Is it safe to delete Fabric contents in ~/Library/Caches in iOS APP

There're 2 folders in ~/Library/Caches in our iOS APP:
com.crashlytics.data
io.fabric.sdk.ios.data
It seems that they're used by Fabric?
I want to add a feature to delete all contents in the Caches folder, and I'm wondering if it's safe to delete these 2 folders?
If I delete the 2 folders when APP is running, what will happen if there're crashes in APP? Will the crash reports still be sent to Fabric?
Any advice would be appreciated.
Todd from Fabric here. It is not safe to delete these programmatically as they contain our crash report data. The folder Library/Caches/com.crashlytics.data/ is where crashes are uploaded from when your app relaunches. Thanks!
As per Apple Docs:
Put data cache files in the Library/Caches/ directory. Cache data can be used for any data that needs to persist longer than temporary data, but not as long as a support file. Generally speaking, the application does not require cache data to operate properly, but it can use cache data to improve performance. Examples of cache data include (but are not limited to) database cache files and transient, downloadable content. Note that the system may delete the Caches/ directory to free up disk space, so your app must be able to re-create or download these files as needed. (c)
So it means, that these folders can be removed even without any additional features in you app. Feel free to do it by yourself.

Opening up an .ipa file - Piracy

How easy is it to open up an app submitted to Apple's store?
I'm going to submit a new app to the store soon, and want to protect the app file from being opened up to the source-code. So for instance, if I were to download my own app, how easy would it be to pull out all the .h and .m files and recreate it in Xcode?
Does Apple encrypt it somehow?
What steps can I take to mitigate the code being viewed?
EDIT: Allow me to rephrase the question a little better - can I take decompiled code and make it human-readable?
An IPA is just a zip. But you don't even need to access the IPA.
Just get iExplorer and access all available assets of your installed apps from your Mac.
The m files however build a compiled binary and can not be read (if you consider de-compiled code as not readable, as I do)
Adding on the answer, it is possible to decompile the binary, but the only thing that would be directly removable from the binary itself would be the headers (or to my knowledge of what I've seen). Then the application would be reverse engineered from there. That would probably be the only thing I'd be worried about when it comes to people stealing my code.

Files security in XCode project

I am trying to build an iOS application which has a PDF file emdebbed in it, and I don’t want the user to access or find it by unpacking the IPA file. I found that if I UNCHECK the “Add to Target” check box (when I drag and drop the PDF file into my project), the PDF file will be hidden and no one can see it after showing the IPA contents.
My question is, should I be worry from this case, in another word, if I unchecked this option, will I face any issue in publishing my application or in deploying/supporting any of my targeted devices, or should I be worry from any issue may face the users in reading this PDF through my application?
I did some research regarding this point, but I couldn’t find any good or clear answer, I appreciate any help in this.
If you uncheck the "Add to target" button it means that the .pdf file will not be packed to the .ipa file and it will not be accessible at all when someone downloads your app. So this is definitely not an option for what you want to achieve. It is better to encrypt the pdf file and decrypt it on runtime if you dont want it to be accessed when someone unpacks the .ipa file.
How important is your security? You could just zip it, then name the file something other than "*.zip".
However that would not stop someone who was determined. You would be advised then to use real encryption.
But even that would not stop a truly-determined attacker, who might use a jailbroken device to capture your PDF while it was loaded in your program's memory.
You can make it difficult to get at your PDF, but if you can get at it from your App, then I myself could get at it if I downloaded your app to my device.

Where to save downloaded data that can't be recreated?

I created magazine reader app that uses png images as pages. When user downloads magazine, all png images are downloaded and stored in Caches folder.
Problem with Caches is that files in there can be apparently deleted anytime. Since app is designed to be used in offline mode as well, re-downloading of missing pages is impossible.
I tried to save it into Documents folder but my app got rejected, this apparently is not proper place for them.
So my question is, where can I put them to make that iOS won't delete them? I don't need them to be backed up to itunes or synced or anything like that, I just need them to stay there until I remove them.
I tried looking into the documentation but I could not find a category that would fit my needs, am I missing something trivial?
EDIT: I need to support iOS 4 as well
http://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html
Put it in the Libary Folder
Handle support files
—files your application downloads or generates and can recreate as needed—in one of two ways:
In iOS 5.0 and earlier, put support files in the /Library/Caches directory to prevent them from being backed up
In iOS 5.0.1 and later, put support files in the /Library/Application Support directory and apply the com.apple.MobileBackup extended attribute to them. This attribute prevents the files from being backed up to iTunes or iCloud. If you have a large number of support files, you may store them in a custom subdirectory and apply the extended attribute to just the directory.
Apple has a tech note that addresses this at http://developer.apple.com/library/ios/#qa/qa1719/_index.html
It shows sample code for setting a no-backup attribute on files.

Resources