2012-07-25 112 views
2

我試圖從這裏使用SOLStumbler:Accessing & Using the MobileWiFi.framework來掃描wifi網絡。我知道這不是由蘋果支持,但它是用於教育目的和實驗。我將下列文件添加到我的應用程序中,它編譯得很好,但它總是以一個錯誤代碼退出。 (作爲「.m」文件的一部分。)有誰知道如何使這個工作?iPhone Wifi掃描Stumbler

SOLStumbler.h

SOLStumbler.m

SOLStumbler.m的這個部分總是輸出一個字母錯誤。通常e但有時u

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

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

我的視圖控制器代碼:

#import "SOLStumbler.h" 

-(void)viewDidLoad{ 
    SOLStumbler *networksManager = [[SOLStumbler alloc] init];  
    [networksManager scanNetworks]; 
    NSLog(@"%@", [networksManager description]); 
    [networksManager release]; 
} 
+1

**其中**錯誤代碼?請不要告訴我們這是行不通的。告訴我們什麼不起作用,以及你看到了什麼症狀。你在調試器中運行了嗎?你看見什麼了?你的'NSLog'語句是什麼打印出來的? – Nate 2012-07-26 00:27:03

+0

我添加了更多關於錯誤陳述的信息。它作爲SOLStumbler.m文件的代碼 – MrHappyAsthma 2012-07-26 17:58:43

+0

的一部分輸出單個字母是否適用於越獄手機? – Nate 2012-07-28 00:34:42

回答

2

你試圖使用SOLStumbler代碼是很老。這些東西(例如WiFiManager)位於私人框架中。這意味着蘋果可以並經常改變它,或者從操作系統版本轉移到版本。

我假設你現在在使用iOS 5?

我登錄到我的iOS 5手機,而事實上,

/System/Library/SystemConfiguration/WiFiManager.bundle/ 

不存在。所以這就是你的代碼失敗的原因。

Have a look at this useful thread.

看起來你現在可以找到當量(?)在IPConfiguration框架功能。試試這個代碼:

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

我跑了一個越獄的iOS 5.0.1的手機和它的工作(加載dylib,發現幾本Apple80211功能)。從我鏈接到的那個線程看來,您可能需要在越獄手機上安裝/Applications,才能完全正常工作。或者,可能不得不亂用增加一些權利到您的沙盒應用程序。

+0

謝謝你。我只需要爲我的操作系統版本找到相應的框架!謝謝! :D – MrHappyAsthma 2012-07-28 06:38:23

+0

libHandle = dlopen(「/ System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration」,RTLD_LAZY);
不適用於iPhone 5S OS 7.1 – vualoaithu 2014-04-17 01:49:24