I'm trying to run airport command to scan my wireless networks. Right now, the approach is to use NSTask. I'm running it as follow:
NSString *command = [NSString stringWithFormat:@"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s"];
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/sh"];
NSArray *args = [NSArray arrayWithObjects:@"-c", command, nil];
[task setArguments: args];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
[task launch];
[task waitUntilExit];
NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile];
NSString *string = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSLog(@"RESULT: %@", string);
The problem is that its output comes as "RESULT:" (empty output). Additionally, when I run the same command with "-I" option, it correctly lists my current network statuses. So, I suppose that I'm mistaking on how to proper read the output of the airport command with -s option. Can someone give a hint on how to proper read it?
Ok. By deeply investigating issues here, I've found this in my Console logs:
Well... looks like it is a permission issue. I'm still investigating here.
EDITED #1: Ok. If your app is sandboxed for Apple Store, sandbox deny NSTask from using airport scan!