Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide code in static library (iOS Obj-C)

I'm working to create an iOS static library that I wish to sell. I've walked through the steps for the initial builds and have generated the .a/.h output.

When I include these files in a separate project, I don't see any way to browse the contents on the .a file.

HOWEVER, when a line of code in my library crashes the app (like I said, it's still in development), the debugger shows the entire class (.m) file to me. What's up with this?

I don't really understand what all goes into static libraries, and I'm not sure I compiled that version for both simulator and device. Could that have something to do with it? If so, could someone explain why?

Thanks!!!

like image 616
mbm29414 Avatar asked Jul 13 '11 01:07

mbm29414


1 Answers

Don't worry, your source code is not included in the archive (.a) file.

Xcode is smart enough to find the source code file on your computer, based on the debugging information embedded in the file. If you build the library using the "Release" configuration (or otherwise modify the build settings so that debugging symbols are stripped) and don't have the source anywhere on the machine, a developer will have to resort to their knowledge of x86 or ARM assembly to figure out how your code works.

By the way:

  • Since a lot of Objective-C is handled at runtime, a lot of class names and selector names will be visible in your library. That's just how it works. You could try to obfuscate it, but I think your time is better spent writing more useful code to sell.

  • If you want to give people a static library for iOS development, you'll want to build versions for the iOS Simulator (x86) and the iOS Device (arm) and then use lipo to combine them into a single fat static library. Search around for "lipo xcode fat static library" for different ways to do this. Some solutions are more convoluted than others.

like image 102
benzado Avatar answered Nov 15 '22 14:11

benzado