1

I was given an static library (.a extension file) that I have to use in a project, however I need to modify some of the source code before it is useful to me. What is the best way to accomplish this?

Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118

4 Answers4

4

The easy-but-most-of-the-time-not-applicable solutions are subclassing or extending.

You can also try to decompile the .a file if its licence authorizes it: cf. Decompiling Objective-C libraries, but it can be tricky and/or illegal.

Community
  • 1
  • 1
Mick F
  • 7,312
  • 6
  • 51
  • 98
0

You cannot modify a static library, your best bet is to try to get access to the sources or ask the author to modify it for you.

lawicko
  • 7,246
  • 3
  • 37
  • 49
0

You may use a Objective C extension.

For example, there's a [MyClass myMethod] in the .a lib, and you want to change this one, the following code might be used:

#import "MyClass.h"
@interface MyClass( CategoryName )
-(void)myMethod;
@end

@implementation MyClass( CategoryName )
-(void)myMethod
{
    //new implementation goes here
}
@end
Zhao Xiang
  • 1,625
  • 2
  • 23
  • 40
0

You cannot modify a library, only extend. That's kind of the point - to distribute the functionality behind your code without people being able to read it.

ingh.am
  • 25,981
  • 43
  • 130
  • 177