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?
Asked
Active
Viewed 6,004 times
4 Answers
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.
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
-
what is CategoryName ? – Husein Behboudi Rad May 05 '15 at 04:15
-
This answer is completely wrong. Swizzling using categories has undefined behavior. – fpg1503 Jun 23 '16 at 14:09
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