ios - 使用 CTGetSignalStrength() 计算 IOS 信号强度

标签 ios objective-c xcode swift ios8

我已经开始为 iOS 8.3 开发一个非 Apple 商店应用程序,它可以测量并返回以 dB 为单位的接收信号强度指示器 (RSSI) 值。我可以访问名为 VAFieldTest 的 Xcode 项目的 git 存储库,该项目使用 Core Telephony 框架来访问诸如单元 ID、服务 mnc、RSSI 等信息。但是,项目构建失败并返回以下内容错误:

    Ld /Users/rajesh/Library/Developer/Xcode/DerivedData/VAFieldTest-dmyrokwehbyuqcauvwpiouivlnqy/Build/Products/Debug-iphonesimulator/VAFieldTest.app/VAFieldTest normal i386
    cd /Users/rajesh/Documents/VAFieldTest
    export IPHONEOS_DEPLOYMENT_TARGET=4.0
    export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.4.sdk -L/Users/rajesh/Library/Developer/Xcode/DerivedData/VAFieldTest-dmyrokwehbyuqcauvwpiouivlnqy/Build/Products/Debug-iphonesimulator -F/Users/rajesh/Library/Developer/Xcode/DerivedData/VAFieldTest-dmyrokwehbyuqcauvwpiouivlnqy/Build/Products/Debug-iphonesimulator -F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.4.sdk/System/Library/PrivateFrameworks -filelist /Users/rajesh/Library/Developer/Xcode/DerivedData/VAFieldTest-dmyrokwehbyuqcauvwpiouivlnqy/Build/Intermediates/VAFieldTest.build/Debug-iphonesimulator/VAFieldTest.build/Objects-normal/i386/VAFieldTest.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=4.0 -framework Foundation -framework UIKit -framework CoreGraphics -framework CoreTelephony -weak_framework VoiceServices -Xlinker -dependency_info -Xlinker /Users/rajesh/Library/Developer/Xcode/DerivedData/VAFieldTest-dmyrokwehbyuqcauvwpiouivlnqy/Build/Intermediates/VAFieldTest.build/Debug-iphonesimulator/VAFieldTest.build/Objects-normal/i386/VAFieldTest_dependency_info.dat -o /Users/rajesh/Library/Developer/Xcode/DerivedData/VAFieldTest-dmyrokwehbyuqcauvwpiouivlnqy/Build/Products/Debug-iphonesimulator/VAFieldTest.app/VAFieldTest

ld: -pie can only be used when targeting iOS 4.2 or later
clang: error: linker command failed with exit code 1 (use -v to see invocation)

起初我认为这是由于新库的链接,但经过检查,构建依赖项已经包含在内并且没有帮助。我想自己调用 Core Telephony 方法,但官方文档没有列出在 iOS 8.3 中访问这些核心功能的方法。列出的方法可在开发人员文档库中找到,但不包含必需的方法。

如何在 iOS 8.3 中获取 RSSI 值?我正在使用 Xcode 6.4 beta。

最佳答案

你可以使用这个获取信号强度:

UIApplication *app = [UIApplication sharedApplication];
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
NSString *dataNetworkItemView = nil;

for (id subview in subviews) {
    if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarSignalStrengthItemView") class]]) {
        dataNetworkItemView = subview;
        break;
    }
}

int signalStrength = [[dataNetworkItemView valueForKey:@"signalStrengthRaw"] intValue];

NSLog(@"signal %d", signalStrength);

关于ios - 使用 CTGetSignalStrength() 计算 IOS 信号强度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29938260/

相关文章:

ios - Xcode 11.2 中的 IconRenderer 警告

ios - 在应用程序内购买。已发送但无法接收的产品 ID

ios - 滚动时 UIBezierPath 问题的舍入

ios - 如何从选定的 UICollectionView 单元格中获取数据?

objective-c - Objective-C 中的插入符号

swift - 您可以在 Swift 中加载应用程序之前进行测试设置吗?

ios - 在 iOS 中的按钮下添加虚线

ios - 如何在应用程序进入后台时发送本地通知

ios - 在模态视图 Controller 后面更改 View Controller

Xcode 4 无法识别框架 header 目录已提交 (GIT)