Search code examples
xcodelarge-data-volumes

Initializing large arrays efficiently in Xcode


I need to store a large number of different kind of confidential data in my project. The data can be represented as encoded NSStrings. I rather like to initialize this in code than read from a file, since that is more secure.

So I would need about 100k lines like this:

[myData addObject: @"String"];

or like this

myData[n++] = @"String";

Putting these lines in Xcode causes compile time to increase extensively up to several hours (by the way in Eclipse it takes a fraction of a second to compile 100k lines like this)

What would be feasible secure alternatives?

(please do not suggest reading from a file since this makes the data much easier to crack)


Solution

  • Strings in your code can be readily dumped with tools like strings.

    Anyway, if you want to incorporate a data file directly into the executable, you can do that with the -sectcreate linker option. Add something like -Wl,-sectcreate,MYSEG,MYSECT,path to the Other Linker Commands build setting. In your code, you can use getsectdata() to access that data section.

    However, you must not consider any of the data that you actually deliver to the end user, whether in code or resource files, as "confidential". It isn't and can never be.