Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load new generated private API headers in iOS?

I'm dummy in iOS especially in private API.

I have application for testing and now I need to use private API (this application not for App Store).

I downloaded generated headers from iOS-Runtime-Headers and what next?

Under /System/Library/ I have list of libraries that contain Frameworks, ... ,PrivateFrameworks as well.

Do I need to replace original framework with ones I copied from iOS-Runtime-Headers?

Because I have other applications that use Public API only and I don't want to damage them.

From posted link they tell to validate library for example by:

NSBundle *b = [NSBundle 
        bundleWithPath:@"/System/Library/PrivateFrameworks/GAIA.framework"];
BOOL success = [b load];

But here the path points to original path.

Or I miss something,

Thank you

like image 227
snaggs Avatar asked Apr 10 '14 13:04

snaggs


2 Answers

First of all, don't replace any headers which are provided by Apple.

Generally, it's done one of two ways:

1) You can copy some of these headers to your project and just include these files the same way as you include any other headers

#import "SomeHeader.h"

2) Sometimes you have to sanitize them (edit them) a little bit. Quite often, these headers has something like in in them:

#import "NSObject.h"

And compliller won't be able to find it, because NSObject is built-in class. So, you need to remove this like.

3) If you just need couple of methods out of it, then Tuukka Nori solution is right.

On top of these, you will need to link (statically or dynamically) against appropriate private framework (just including headers isn't enough).

like image 190
Victor Ronin Avatar answered Nov 04 '22 20:11

Victor Ronin


Don't replace any files. Instead, write a header file with the symbol that you intend to use. If you need an Objective-C method, add a category with a unique name, e.g.

@interface NSString (MyOwnPrivateCategory)
- (void) privateMethodDeclaredInRuntimeHeaders;
@end

Import it and use the method as you like.

The sample code given shows how to load a framework at runtime in case you don't want to link to it. Since some frameworks are private, they might not be available in all versions of iOS.

like image 4
tsnorri Avatar answered Nov 04 '22 20:11

tsnorri