OK, so here's what I need :
I have a (rather big) binary .plist associated with my app, containing info that I wouldn't really like it if a user would access it and view the contents (as would normally happen with a regular un-encrypted plist file, binary-or-not).
I want to encrypt the .plist (using a pass)
Include the encrypted .plist in my app bundle
Decrypt the .plist at app launch
How would you go about it? Is there any built-in way to make it easier for me to achieve that?
P.S. I don't think it'll make much of a difference, but I'm interested in a working OSX solution, not an iOS one
Related
In our app we have lots of photos that we need to read while using the app, we have to also orgenize them into groups/categories.
this option is to make a plist with their names, and just put them into the app and read the plist.
create folders inside the app, order them inside, and read the specific folder.
Option 2 took me days and I couldn't even make it work reliably, and it also seems not the right way to work for some reason.
Option 1, the problem is that if you have 100 files you have to edit your plist every time again for a new file you add.
Is there a way to make option 1 outside of xcode so I can put all files in a folder on my mac, get their plist, and put this plist inside Xcode ?
What's the right way to achieve this ?
plist is just a simple XML file. You can create the plist file and add to xcode as any normal file to the bundle and read it.
macOS comes with two command-line tools for manipulating plists:
/usr/bin/plutil can convert a plist between formats. You might like this because you could write your photo catalog in JSON using whatever tools you like, then convert it to a plist. Of course, then you could just use JSON directly in your app…
/usr/libexec/PlistBuddy (note that /usr/libexec is not normally in one's PATH) can modify a plist in place, adding, removing, or changing entries.
Both of these tools have man pages (man plutil, man PlistBuddy) and substantial built-in help (plutil -h, /usr/libexec/PlistBuddy -h).
First, you're making a false assumption. There is no need to use a plist file here. An ordinary text file listing the names will do just fine, and you can just make up your own format to dictate groups and suchlike. And that sort of file is trivially easy to maintain.
Second, your rather confused claim that "Option 2 took me days and I couldn't even make it work reliably, and it also seems not the right way to work for some reason" is just a cop-out. Folder references are not a difficult thing to use (you can configure them in the Finder, which is as simple as you can get), they do work just fine, and they are a perfectly reasonable solution here.
I need to be able to configure my app via configuration file.
How do I go about it?
The first thing that comes to my mind is having a .plist file that stores values and to have an singleton class and ask that class for values whenever I create element in question in code.
Or is there any better way to do this?
Depends on the amount of content and size of the configuration file.
If it's a couple of key-value values, I would just go with NSUserDefaults.
If it's a bit more, arrays or more advanced data models, I would go with a .plist. But remember to move the default .plist into the /Documents folder, you are not allowed to edit files in the app bundle.
i have an iOS App which loads and .txt file from app's root. If i use iFunBox or any iPhone Browsers i can see that .txt file, how can I hide it? I think it's all about security of this file, encode/decode. Please help me. Any advice, source codes, examples. I'm new here. thanks
The short answer: You can't
The long answer: No matter what you do, you will end up having a copy of the decrypted contents in memory at some point so a crafty cracker will be able to copy the contents out of memory. The best you can do is make it not worth their trouble. This includes using pure C, never storing the contents in one variable (always concat, etc), and encrypting the file with an industry standard encryption like AES-256. Good luck.
I'm not sure that it is possible to protect the file any more than what apple already does. Even if you could, I don't think It would really be worth your trouble to do so unless the .txt file is something that you really need to protect.
I have a custom requirement in one of my products and I need to protect or encrypt files that are stored inside the NSDocumentsDirectory folder. Even if these documents are mailed (The app has the ability to mail documents) to some other person , he or she will not be able to open this document without using my app (I will be using open in functionality of email attachments). So basically only the application can access all these documents and without the app the documents should be mere junk. IS there any way to do it, or has any one done something before.
I also saw this but could not get a complete idea.
If you want a quick and easy method for data that doesn't need serious security, just zip the files with a fixed password.
ZipArchive is a good library for this.
For a more serious approach, check iOS - Protecting files with a custom encryption key?
The other post you mentioned works on the concept of password protecting the files, I had encountered the same issue that was for my custom defined files in which our team, encoded the contents of the file on random locations, and saved it.
Only our Application could decode it correctly as we had the key :)
It was a windows application, It would work here also.
I have a plist in my Resources folder that I'm using to store conversion information. I'd like to give the user the ability to "turn off" certain units so that those units will never be used in conversions. I don't want to have to maintain two lists with the conversion information in it.
I am able to save data back to that plist file in the stimulator. (using writeToFile and the pathForResource). I'm wondering if this is a problematic approach.
Will there be an issues with this on deployment? (i.e. will Apple seal the plist)
What will happen if I push out an upgrade? What if that upgrade contains new units added to the list?
Would doing something like copying the plist to the user's documents directory make sense?
It is not possible to change the app bundle. Further the app is signed. Instead copy the plist to the documents directory on first start and access from there.
No whatever is in the application bundle is offlimit has the DRM on iPhone needs it to stay the same. You should save your preferences in the Apllication Document folder or Preference folder.
Use an iOS Settings Bundle...