iOS6.1:尝试访问WiFi RSSI时出现问题(MobileWiFi.framework) [英] iOS6.1: Problems while trying to access WiFi RSSI (MobileWiFi.framework)

查看:222
本文介绍了iOS6.1:尝试访问WiFi RSSI时出现问题(MobileWiFi.framework)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有iOS6.1的iPod Touch 4G和带有有效配置文件的Xcode 4.6.3来访问我周围几个AP的RSSI值。我已经阅读了关于这个主题的一些讨论,最好的方法是使用私有的Framework MobileWifi。由于这个项目仅供私人使用,我很满意。

I'm trying to access the RSSI values of several APs around me using an iPod Touch 4G with iOS6.1 and Xcode 4.6.3 with a valid Provisioning Profile. I've read some discussions about this topic and the best way to do this seems to be using the private Framework MobileWifi. Since this project is for private usage only I'm ok with that.

根据这个网站我需要特殊权利才能访问MobileWiFi功能。我以前从未使用过权利,但根据一些例子,我的.entitlement文件如下所示:

According to this website I need a special entitlement in order to access the MobileWiFi functions. I've never worked with entitlements before, but according to some examples my .entitlement file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>keychain-access-groups</key>
    <array>
        <string>$(AppIdentifierPrefix)com.apple.wifi.manager-access</string>
    </array>
</dict>
</plist>

我还做了越狱并安装了AppSync,以便根据无效的权利去除错误。我可以在我的iPod上运行应用程序,但每次我想检查网络或设备时应用程序崩溃。这是我到目前为止的代码:

I also did a jailbreak and installed AppSync in order to get rid of errors according to invalid entitlements. I am able to run the app on my iPod, but every time i want to check for networks or devices the app crashes. Here is my code so far:

WiFiManagerRef manager = WiFiManagerClientCreate(kCFAllocatorDefault, 0);
if (!manager)
    NSLog(@"ERROR: Couldn't create WiFiManagerClient!");

CFArrayRef devices = WiFiManagerClientCopyDevices(manager);
if (!devices)
    NSLog(@"ERROR: devices is NULL");

CFArrayRef networks = WiFiManagerClientCopyNetworks(manager);
if (!networks)
    NSLog(@"ERROR: networks is NULL");

NSLog(@"manager: %@", manager);
NSLog(@"%d devices: %@", (int)CFArrayGetCount(devices), devices);
NSLog(@"%d networks: %@",(int)CFArrayGetCount(networks), networks);

似乎 WiFiManagerClientCopyDevices WiFiManagerClientCopyNetworks 方法返回一些错误的值,如果我在调用这些方法后设置一些检查点来检查它们的地址是0x00000000,并且应用程序在返回其数组计数时由于EXC_BAD_ACCESS而崩溃。

It seems that the WiFiManagerClientCopyDevices and WiFiManagerClientCopyNetworks methods return some bad values, if I set some checkpoint to check their addresses they're 0x00000000 after calling these methods and the app crashes due to EXC_BAD_ACCESS when returning their array count.

我读过如果我不使用正确的权利,MobileWifi功能将无效。其他一些人写道,不是.entitlement文件,而是应该使用entitlement.xml文件并使用 ldid 来代码签署应用程序并将其传输到设备上,但我不知道我喜欢手动执行此操作,因为我更喜欢在编码时使用Xcode的调试器和控制台。

I've read that the MobileWifi functions won't work if I won't use the correct entitlements. Some others wrote that instead of a .entitlement file one should use a entitlement.xml file and use ldidto code sign the app and transfer it onto the device, but I don't like to do this manually since I prefer using Xcode's debugger and console while coding.

我花了一整天试图摆脱这些问题,但我没有找到任何解决方案,所以如果有人可以帮我解决这个问题,我会很高兴!

I spent a whole day trying to get rid of these problems but I didn't find any solutions, so I would be really glad if someone could help me out with this!

推荐答案

对我而言,这看起来像你的权利文件不正确。

To me it looks like your entitlements file is incorrect.

您已使用 wifi.manager-access 权利替换了您的包ID。您需要保留 keychain-access-group ,并在文件末尾添加 wifi.manager-access 权利作为新的键/值对。

You have replaced your bundle id with the wifi.manager-access entitlement. You need to leave the keychain-access-group as it was and add the wifi.manager-access entitlement at the end of the file as new key/value pair.

在Xcode中生成一个新的授权文件并添加以下键/值对。

Generate a new entitlement file in Xcode and add the following key/value pair.

    <key>com.apple.wifi.manager-access</key>
    <true/>

您的自定义权利文件最终应该是这样的:

Your custom entitlements file should finally look something like that:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>keychain-access-groups</key>
    <array>
        <string>YOUR_APP_BUNDLE_ID</string>
    </array>
    <key>com.apple.wifi.manager-access</key>
    <true/>
</dict>
</plist>

这篇关于iOS6.1:尝试访问WiFi RSSI时出现问题(MobileWiFi.framework)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆