2

I am trying to use the SOLStumbler from here: Accessing & Using the MobileWiFi.framework to scan for wifi networks. I am aware that this is not supported by apple but it is for educational purposes and experiments. I add the following files to my application and it compiles fine but it always exits with an error code. (As part of the ".m" file.) Does anyone know how to get this working?

SOLStumbler.h:

SOLStumbler.m:

This part of SOLStumbler.m always outputs a single letter error. Normally e but sometimes u.

libHandle = dlopen("/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager", RTLD_LAZY);

    char *error;
    if (libHandle == NULL && (error = dlerror()) != NULL)  {
            NSLog(@"%c",error);
            exit(1);
    }

My ViewController code:

#import "SOLStumbler.h"

-(void)viewDidLoad{
    SOLStumbler *networksManager = [[SOLStumbler alloc] init];      
    [networksManager scanNetworks]; 
    NSLog(@"%@", [networksManager description]);
    [networksManager release];  
}
Community
  • 1
  • 1
MrHappyAsthma
  • 6,332
  • 9
  • 48
  • 78
  • 1
    **Which** error code? Please don't tell us that it's not working. Tell us what isn't working, and what symptoms you are seeing. Did you run in the debugger? What did you see? What did your `NSLog` statements print out? – Nate Jul 26 '12 at 00:27
  • I added in more info about the error statement. It outputs a single letter as part of the SOLStumbler.m file's code – MrHappyAsthma Jul 26 '12 at 17:58
  • is this for a jailbroken phone? – Nate Jul 28 '12 at 00:34
  • I think that your error printing code is wrong. – Richard J. Ross III Jul 28 '12 at 01:02
  • @RichardJ.RossIII, he took that code right out of the SOLStumbler source. Anyway, you don't even get to that code unless `libHandle == NULL`, which was a problem caused by the framework path having changed. – Nate Jul 28 '12 at 08:00

1 Answers1

2

The SOLStumbler code you're trying to use is pretty old. This stuff (e.g. WiFiManager) is in a private framework. That means Apple can, and often will, change it or move if from OS version to version.

I assume you're now using iOS 5?

I logged in to my iOS 5 phone, and indeed,

/System/Library/SystemConfiguration/WiFiManager.bundle/

does not exist. So that's why your code fails.

Have a look at this useful thread.

It looks like you can now find equivalent (?) functions in the IPConfiguration framework. Try this code:

libHandle = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY);

I ran it on a jailbroken iOS 5.0.1 phone and it worked (loaded the dylib and found a few of the Apple80211 functions). From that thread I linked to, it looks like you may need to have this installed in /Applications on a jailbroken phone, in order to work fully. Or, possibly have to mess around with adding some entitlements to your sandboxed app.

Nate
  • 31,017
  • 13
  • 83
  • 207
  • Thank you for this. I'll just have to find the equivalent framework for my OS version! Thanks! :D – MrHappyAsthma Jul 28 '12 at 06:38
  • libHandle = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY);
    not working with iphone 5S OS 7.1
    – vualoaithu Apr 17 '14 at 01:49