-3

As the question suggests, I'd like to know how I can use private API in private, company IOS 8.1 - 8.1.2 app. It will NOT be going through the app store. I need to have programmatic control over airplane mode, wifi, bluetooth, and cellular data. I've read online over and over again that it's not possible, but I can't believe this to be true. I've tried creating an NSObject category and simply pasting the method I want to use to turn on wifi. However, I keep getting a Matcho-Link Error. I have added the corresponding 'sharing' framework to the library, so not sure what the problem is.

My Category

@interface NSObject (Wifi)
- (void)setWifiEnabled:(BOOL)arg1;
@end

My ViewController's Interface

    #import <UIKit/UIKit.h>
#import "NSObject+Wifi.h"
@interface ViewController : UIViewController


@end

Viewcontroller's Implementation

    #import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)enableWifi:(UIButton *)sender {
    NSObject * wifi = [[NSObject alloc]init];
    [wifi setWifiEnabled:YES];
}

@end

Error Message:

ld: framework not found Sharing
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Again, the 'Sharing.framework' is added and linked to project and I've checked "Copy files if needed". How do I get passed this error?

Bryan Chen
  • 45,816
  • 18
  • 112
  • 143
Rafael
  • 9
  • 1

1 Answers1

3

That isn't how private APIs work. Sorry.

You can't just make up a method name for the feature you want; you need to define and call a class and/or method that matches with code that already exists in Apple's frameworks. Finding these classes/methods is the difficult part, and tends to involve a lot of poring through disassembly. Long story short, it's a nontrivial task.

There is apparently a method with a similar name on the SBWiFiManager class, although I can't confirm whether that still works. (It might not; undocumented interfaces are subject to change.) You might want to give that a try.

In any case, the Sharing framework you tried to link against is completely unrelated. Remove it from your project.

  • Huh? I didn't just pull the method out of thin air, silly. I got the headers from Github. But it seems I got a header from a previous version of IOS that is no longer available. Can you do me a favor and tell me why I got down voted? It's my first question and I want to know what I did wrong. Similar questions are on Stack, but I haven't found a clear answer for IOS 8. Thanks for leading me to the right direction, though. I should be looking for how to do a class dump. I'll also check SBWiFiManager. – Rafael Jan 22 '15 at 05:43