Dan*_*elG 28 objective-c ios ios9 xcode7
我正在尝试让我的应用程序在Xcode 7测试版中工作,但我遇到了这个例外:
NSInternalInconsistencyException: 'Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)'
Run Code Online (Sandbox Code Playgroud)
这是callstack:
0 CoreFoundation 0x00000001063a89b5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000105e20deb objc_exception_throw + 48
2 CoreFoundation 0x00000001063a881a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00000001036f8b72 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 CoreLocation 0x00000001031c7fe3 CLClientGetCapabilities + 8270
5 peach 0x00000001020c0ee9 -[PeachesBatteryOptimizer initWithDelegate:] + 761
6 peach 0x0000000102086d25 -[PeachAgent init] + 1141
7 peach 0x000000010208682c __23+[PeachAgent instance]_block_invoke + 76
8 libdispatch.dylib 0x00000001068604bb _dispatch_client_callout + 8
9 libdispatch.dylib 0x000000010684bedc dispatch_once_f + 543
10 peach 0x00000001020867bb +[PeachAgent instance] + 139
11 peach 0x0000000102086f4d +[PeachAgent createInstanceWithAppKey:andInternal:useDevApi:] + 93
12 peach 0x0000000101e2b710 -[ABCAppDelegate createPeachAgent] + 368
13 peach 0x0000000101e28703 -[ABCAppDelegate application:didFinishLaunchingWithOptions:] + 243
...
Run Code Online (Sandbox Code Playgroud)
有没有人在iOS 9 beta 5上看过这个?
igr*_*ech 60
我设法通过做这两件事来解决这个问题:
UIBackgroundModes"位置" 添加到Info.plistNSLocationAlwaysUsageDescription到Info.plist从iOS 11开始,密钥命名为:
NSLocationAlwaysAndWhenInUseUsageDescription 和 NSLocationWhenInUseUsageDescription如果像我一样想要[CLLocationManager setAllowsBackgroundLocationUpdates:]在单独的项目模块/静态库中使用,这是另一种解决方案.如果使用该模块/库的应用程序没有位置后台功能,您将会崩溃...我使用以下方法使呼叫安全:
- (void) setAllowsBackgroundLocationUpdatesSafely
{
NSArray* backgroundModes = [[NSBundle mainBundle].infoDictionary objectForKey:@"UIBackgroundModes"];
if(backgroundModes && [backgroundModes containsObject:@"location"]) {
if([mLocationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {
// We now have iOS9 and the right capabilities to set this:
[mLocationManager setAllowsBackgroundLocationUpdates:YES];
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有类似的问题。以下是修复此崩溃问题的步骤(使用 Xcode 11.3)。
Privacy - Location usage description在Info.plist您的项目。Background Modes为Capability你的项目目标。Location Update选项小智 5
我在混合应用程序上遇到了同样的问题。
我已启用后台模式。
Apple 拒绝了我的应用程序。据说没有后台模式的功能。
所以我对“BackgroundGeolocationDelegate.m”进行了以下更改
locationManager.allowsBackgroundLocationUpdates = NO;
然后:
if (authStatus == kCLAuthorizationStatusNotDetermined) {
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { //iOS 8.0+
NSLog(@"BackgroundGeolocationDelegate requestAlwaysAuthorization");
[locationManager requestWhenInUseAuthorization];
}
}
Run Code Online (Sandbox Code Playgroud)
没有再发生车祸。
注意:修复仅适用于混合应用程序
| 归档时间: |
|
| 查看次数: |
18085 次 |
| 最近记录: |