title: List / Scan for available WiFis iPhone
body: <p>I'm searching for a way to present available WiFis in an iPhone App.
  So far my research resulted in the following:</p>
  <ul>
  <li>Apps that implement(ed) such a functionality were removed from the AppStore (means you can't deploy the App via AppStore which is fine for me)</li>
  <li>Apple hides the functionality that is necessary for a scan in a private framework and you can't find any explanations/comments/examples on &quot;how to use&quot;</li>
  <li><a href="http://code.google.com/p/iphone-wireless" rel="nofollow noreferrer">http://code.google.com/p/iphone-wireless</a> seems to be most promising. anyway, i can't figure out how to include the delivered sources in my code so that it runs on a device</li>
  </ul>
  <p>Even the adaptions that are mentioned htt ://code.google.com/p/iphone-wireless/issues/detail?id=26 didn't get me the desired results. The most progress was ending up with a</p>
  <blockquote>
  <p>dlopen error: dlopen(/System/Library/SystemConfiguration/Aeropuerto.bundle/Aeropuerto, 1): image not found
  failed: __Apple80211Associate</p>
  </blockquote>
  <p>message after launching the app on a device (iPhone 3GS; iOS 3.1.3).</p>
  <p>Used source code that procudes the error is here:</p>
  <pre><code>NSMutableDictionary *networks;
  bool scanning;
  void *libHandle;
  void *airportHandle;
  int (*open)(void *);
  int (*bind)(void *, NSString *);
  int (*close)(void *);
  int (*scan)(void *, NSArray **, void *);
  
  networks = [[NSMutableDictionary alloc] init];
  // libHandle = dlopen(&quot;/System/Library/Frameworks/Preferences.framework/Preferences&quot;, RTLD_LAZY);
  // libHandle = dlopen(&quot;/System/Library/PrivateFrameworks/Apple80211.framework/Preferences&quot;, RTLD_LAZY);
  libHandle = dlopen(&quot;/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager&quot;, RTLD_LAZY);
  
  open = dlsym(libHandle, &quot;Apple80211Open&quot;);
  bind = dlsym(libHandle, &quot;Apple80211BindToInterface&quot;);
  close = dlsym(libHandle, &quot;Apple80211Close&quot;);
  scan = dlsym(libHandle, &quot;Apple80211Scan&quot;);
  
  open(&amp;airportHandle);
  bind(airportHandle, @&quot;en0&quot;);
  
  NSLog(@&quot;Scanning...&quot;);
  scanning = true;
  NSArray *scan_networks;
  NSDictionary *parameters = [[NSDictionary alloc] init];
  scan(airportHandle, &amp;scan_networks, parameters);
  bool changed;
  for (int i = 0; i &lt; [scan_networks count]; i++) {
      if([networks objectForKey:[[scan_networks objectAtIndex: i] objectForKey:@&quot;BSSID&quot;]] != nil 
         &amp;&amp; ![[networks objectForKey:[[scan_networks objectAtIndex: i] objectForKey:@&quot;BSSID&quot;]] isEqualToDictionary:[scan_networks objectAtIndex: i]])
          changed = true;
      [networks setObject:[scan_networks objectAtIndex: i] forKey:[[scan_networks objectAtIndex: i] objectForKey:@&quot;BSSID&quot;]];
  }
  if(changed) {
      NSLog(@&quot;NetworksUpdated&quot;);
  }
  scanning = false;
  NSLog(@&quot;Scan Finished...&quot;);
  NSLog(@&quot;Found %i networks: %@&quot;, [networks count], networks);
  </code></pre>
  <p>Even if trying one of the other commented lines, it doesn't work:
  program received EXC_BAD_ACCESS and several</p>
  <blockquote>
  <p>warning: check_safe_call: could not restore current frame</p>
  <p>warning: Unable to restore previously selected frame.</p>
  </blockquote>
  <p>What i'm searching are hints how to include iphone-wireless in my project and how to modify the given code?
  An alternative would be a tip on how to scan for WiFis in your environment.</p>
  <p>Would be nice if someone could help.</p>