我正在为iOS应用程序使用PortSIP SDK。在我的应用程序中,当我点击呼叫按钮,应用程序给我的错误。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIDevice deviceType]: unrecognized selector sent to class 0x23a2421b0'
我认为我的应用无法获取设备类型。有什么建议吗?那个错误是什么意思?
z2acfund1#
我在使用PortSIPSDK的演示中遇到了同样的错误,问题是配置中的问题。http://www.portsip.cn/docs/html_man/ios/html/index.html1.将“-ObjC”添加到“构建设置”-〉“其他链接器标志”
qxgroojn2#
UIDevice通常没有deviceType成员,PortSIP SDK中应该有扩展,你应该检查源代码,可能它们并不涵盖所有情况,但是你可以使用下面的代码来检测你的设备类型。
#include <sys/sysctl.h> #include <sys/utsname.h> - (NSString *) platformString{ NSLog(@"[UIDevice currentDevice].model: %@",[UIDevice currentDevice].model); NSLog(@"[UIDevice currentDevice].description: %@",[UIDevice currentDevice].description); NSLog(@"[UIDevice currentDevice].localizedModel: %@",[UIDevice currentDevice].localizedModel); NSLog(@"[UIDevice currentDevice].name: %@",[UIDevice currentDevice].name); NSLog(@"[UIDevice currentDevice].systemVersion: %@",[UIDevice currentDevice].systemVersion); NSLog(@"[UIDevice currentDevice].systemName: %@",[UIDevice currentDevice].systemName); NSLog(@"[UIDevice currentDevice].batteryLevel: %f",[UIDevice currentDevice].batteryLevel); struct utsname systemInfo; uname(&systemInfo); NSLog(@"[NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]: %@",[NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]); NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G"; if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G"; if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS"; if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4"; if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone 4 CDMA"; if ([platform isEqualToString:@"iPhone3,3"]) return @"Verizon iPhone 4"; if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S"; if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (GSM)"; if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)"; if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)"; if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (GSM+CDMA)"; if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)"; if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (GSM+CDMA)"; if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone 6"; if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus"; if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G"; if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G"; if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G"; if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G"; if ([platform isEqualToString:@"iPod5,1"]) return @"iPod Touch 5G"; if ([platform isEqualToString:@"iPad1,1"]) return @"iPad"; if ([platform isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)"; if ([platform isEqualToString:@"iPad2,2"]) return @"iPad 2 (Cellular)"; if ([platform isEqualToString:@"iPad2,3"]) return @"iPad 2 (Cellular)"; if ([platform isEqualToString:@"iPad2,4"]) return @"iPad 2 (WiFi)"; if ([platform isEqualToString:@"iPad2,5"]) return @"iPad Mini (WiFi)"; if ([platform isEqualToString:@"iPad2,6"]) return @"iPad Mini (Cellular)"; if ([platform isEqualToString:@"iPad2,7"]) return @"iPad Mini (Cellular)"; if ([platform isEqualToString:@"iPad3,1"]) return @"iPad 3 (WiFi)"; if ([platform isEqualToString:@"iPad3,2"]) return @"iPad 3 (Cellular)"; if ([platform isEqualToString:@"iPad3,3"]) return @"iPad 3 (Cellular)"; if ([platform isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)"; if ([platform isEqualToString:@"iPad3,5"]) return @"iPad 4 (Cellular)"; if ([platform isEqualToString:@"iPad3,6"]) return @"iPad 4 (Cellular)"; if ([platform isEqualToString:@"iPad4,1"]) return @"iPad Air (WiFi)"; if ([platform isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)"; if ([platform isEqualToString:@"i386"]) return @"Simulator"; if ([platform isEqualToString:@"x86_64"]) return @"Simulator"; return @"Unknown"; }
hec6srdp3#
我的问题与Bruno posted完全相同,因为我的目标是基于Swift Package的C++库,在Package.swift中添加以下linkerSettings解决了这个问题
Package.swift
linkerSettings
linkerSettings: [ .unsafeFlags([ "-ObjC" ]), ]
我的第一次尝试是在cSettings中添加.define("OTHER_LDFLAGS",to: "-ObjC"),但这并没有解决问题,这可能是因为我也在使用cxxSettings,虽然不确定。
cSettings
.define("OTHER_LDFLAGS",to: "-ObjC")
cxxSettings
3条答案
按热度按时间z2acfund1#
我在使用PortSIPSDK的演示中遇到了同样的错误,问题是配置中的问题。http://www.portsip.cn/docs/html_man/ios/html/index.html
1.将“-ObjC”添加到“构建设置”-〉“其他链接器标志”
qxgroojn2#
UIDevice通常没有deviceType成员,PortSIP SDK中应该有扩展,你应该检查源代码,可能它们并不涵盖所有情况,但是你可以使用下面的代码来检测你的设备类型。
hec6srdp3#
我的问题与Bruno posted完全相同,因为我的目标是基于Swift Package的C++库,在
Package.swift
中添加以下linkerSettings
解决了这个问题我的第一次尝试是在
cSettings
中添加.define("OTHER_LDFLAGS",to: "-ObjC")
,但这并没有解决问题,这可能是因为我也在使用cxxSettings
,虽然不确定。