IPConfiguration Apple801Open()在iOS8上崩溃
我正在尝试读取iPhone WIFI连接到AP的RSSI 在iPhone6+ios 8.1.3上使用Xcode 6.1.1 下面的代码在IPConfiguration Apple801Open()在iOS8上崩溃,ios,objective-c,iphone,network-programming,Ios,Objective C,Iphone,Network Programming,我正在尝试读取iPhone WIFI连接到AP的RSSI 在iPhone6+ios 8.1.3上使用Xcode 6.1.1 下面的代码在apple801open()上崩溃,并在iOS 8上获得EXC\u BAD\u访问(Code=1,address=0)。(代码适用于iOS 7.1) 这是为苹果商店以外的应用程序设计的——仅用于临时分发 ================================================================= void *libHandl
apple801open()
上崩溃,并在iOS 8上获得EXC\u BAD\u访问(Code=1,address=0)
。(代码适用于iOS 7.1)
这是为苹果商店以外的应用程序设计的——仅用于临时分发
=================================================================
void *libHandle;
void *airportHandle;
int (*apple80211Open)(void *);
int (*apple80211Bind)(void *, NSString *);
int (*apple80211Close)(void *);
int (*apple80211GetInfoCopy)(void *, CFDictionaryRef *);
NSMutableDictionary *infoDict = [NSMutableDictionary new];
NSDictionary * tempDictionary;
libHandle = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY);
char *dlerror_error;
if (libHandle == NULL && (dlerror_error = dlerror()) != NULL) {
NSLog(@"%s", dlerror_error);
}
apple80211Open = dlsym(libHandle, "Apple80211Open");
apple80211Bind = dlsym(libHandle, "Apple80211BindToInterface");
apple80211Close = dlsym(libHandle, "Apple80211Close");
apple80211GetInfoCopy = dlsym(libHandle, "Apple80211GetInfoCopy");
apple80211Open(&airportHandle);
apple80211Bind(airportHandle, @"en0");
CFDictionaryRef info = NULL;
apple80211GetInfoCopy(airportHandle, &info);
tempDictionary = (__bridge NSDictionary *)info;
apple80211Close(airportHandle);
[infoDict setObject:(tempDictionary[@"RSSI"])[@"RSSI_CTL_AGR"] ? (tempDictionary[@"RSSI"])[@"RSSI_CTL_AGR"] : @"0" forKey:@"RSSI"];
[infoDict setObject:tempDictionary[@"BSSID"] ? tempDictionary[@"BSSID"] : @"null" forKey:@"BSSID"];
[infoDict setObject:tempDictionary[@"SSID_STR"] ? tempDictionary[@"SSID_STR"] : @"null" forKey:@"SSID"];
[infoDict setObject:tempDictionary[@"RATE"] ? tempDictionary[@"RATE"] : @"0" forKey:@"SPEED"];
这是因为苹果从IPConfiguration中删除了80211框架。找不到符号,dlsym返回NULL,并且-崩溃(您知道,您应该始终检查返回值) 首先,这是一个私有框架。在新版本的iOS(8+)中,它被弃用,取而代之的是MobileWifi,以及使用授权(和XPC),以便所有工作都有/usr/libexec/wifid
本文对此有更详细的介绍:Apple80211 API在某些时候(例如iOS 11和12)已从IPConfiguration中删除,但在iOS 13中又重新出现,到今天为止,这些方法仍然存在,并在iOS 13.4.1中运行。我所期望的是,您无法使其工作的原因可能是因为iOS 8您需要上述的
com.apple.wlan.authentication
权限
目前有一种方法可以在应用程序中使用此权限(供您自己使用),但它将在iOS 13.5中停止工作。我也有同样的问题。。。有什么想法吗?谢谢如果苹果确实删除了它,那么它又回来了,苹果80211方法在iOS 13.4.1的IPConfiguration中