2

Possible Duplicate:
Objective-C Code Obfuscation

I am trying to put together an iOS package that can be reused in multiple apps. I would like to be able to bundle it up for others to easily plug in and use, and I would like to obfuscate the code so that no one can read it.

What would you recommend between building a framework, a static library, or another solution to accomplish this and why?

Community
  • 1
  • 1
lavoy
  • 1,876
  • 3
  • 21
  • 36

2 Answers2

6

If you're distributing for iOS, you have two options:

  1. Distribute a precompiled binary and headers
  2. Distribute the source

Since you're asking about hiding stuff, I don't think #2 is what you're looking for.

As for #1, the best you can do is just not tell 3rd party users about more stuff. They'll still be able to use the runtime to find methods and properties and instance variables, etc. If you're doing everything in C-land (ie, no Objective-C classes), then they can still use things like otool to dump symbols.

In short:

It's probably not worth trying to "obfuscate" your code. Just tell them about the stuff they need to know about, then give them a .a file and the headers they need.

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
1

A framework is the standard Cocoa approach to shared code. You can distribute a framework as a compiled code library and a collection of public headers without making any of the underlying Objective-C soure code visible. Of course, a dedicated hacker could still read the machine code, but this would be a big undertaking, and probably not worth the time they would have to spend on it.

If you are really concerned about sensitive code, you could consider an internet-based service, in which your library calls out to a remote server under your control to perform some business logic. This approach is quite a bit more involved, and does not offer as much flexibility for your customers.

e.James
  • 116,942
  • 41
  • 177
  • 214
  • 1
    Since this is tagged 'ios', he can't use a framework. – bbum Jan 06 '11 at 21:37
  • 1
    @bbum: It sounds to me like he is talking about a framework that other developers could download and link with their own apps at compile, not a shared framework that is installed on the device and called at runtime. – e.James Jan 06 '11 at 22:25
  • But people can still debug his framework and see all the source since IOS only allows static libraries bundled into frameworks and not dynamic libraries -- this means that , unless I am mistaken - your answer is not the correct one -- please correct me if I am wrong . – James Roeiter Aug 23 '12 at 08:03