views:

58

answers:

2

Hello! Just I'm curious. I have created a lot of convinient categories to the Objective-C classes (NSObject, NSDictionary, NSString...), as long as very interesting subclasses that makes a lot of popular task in the iPhone/iPad programming, to be as easy as putting only one line of code or firing a method.

I'd like to share this code with others but the problem is, I don't want them to see the real code as long as I spent hours on creating it. Perheps in future I'd also like to sold this piece of code.

So let's assume the file is called Extensions and is divided into two files: Extensions.h (where are about 100 headers) and the Extensions.m - their implementations. I'd like to distribute this class in a way that Extensions.h is 100% public - developer sees the code I've put in that file so he knows how to use those extensions, but Extensions.m should not be visible as a code, but as a library or something like that.

I also would like to make the implementation of above in the custom projects as easy as possible. The best way would be just drag'n'drop and #import Extensions.h in the header.

I'm looking forward to hearing you advices. Regards Chris

+3  A: 

Flurry does this... they distribute a .h file with the headers and a .a file with the code. So looks like you could compile a .a file for distribution.

Michael Kernahan
hmmm. I've just created my extension pack using the Library/Cocoa Touch Static Library template. Added those two files and imported the CoreGraphics and UIKit frameworks in addition to the Foundation that was already present. It generated me the libExtensions.a file. And how can I use that in different project? Where or how should I import that? If I press get info on my project I see the libExtensions.a in Linked Libraries, but the Direct Dependencies plus/minus button is disabled.
Krzysiek Rutkowski
Well for Flurry you just drag and drop the parent directory of the .h and .a files into your project, and choose "Recursively Add to Project" ... then in the files that will use the extensions you need to import the .h file.
Michael Kernahan
Hmmm I don't get it. I have two projects - "test project" where I'd like to use the extension, and the Extension project where I'm building the library. In Extension I only have two files - Extension.h and Extension.m and their builds a libExtensions.a file. So then I've to drag the Extension.h and libExtensions.a to the "test project"? I do and it tells me the NSString cannot respond to md5 method :(. AND BTW: I think if I have to build it using device or simulator SDK?
Krzysiek Rutkowski
We're getting out of my depth... :-) I would say search stack overflow for "iPhone static libraries category" This one looks helpful: http://stackoverflow.com/questions/932856/calling-method-on-category-included-from-iphone-static-library-causes-nsinvalidar
Michael Kernahan
... Just thinking - you might need to include all of the .h files since it is categories in your .a
Michael Kernahan
OK I managed to do some progress. I had to add the -all_load flag in the Other linker flags. Is there any way not to add that flag and do it strictly in code, i. e. in the Extensions.h file? Do I also have to distribute it in the two versions - for Simulator and Device? Cannot it be combined into one .a file?And I have a warning that the Extensions-device.a was "built for unsupported file format which is not the artchitecture being linked (i386)" when I build using Simulator SDK, and the same message about simulator's lib when building for the Device. Is there any way to remove that?
Krzysiek Rutkowski
A: 

deleted..........

Krzysiek Rutkowski