简体   繁体   English

由于'_alwaysRunsAtForegroundPriority',iOS 12.2上的离子应用程序崩溃

[英]Ionic app crashes on iOS 12.2 because of '_alwaysRunsAtForegroundPriority'

On iOS 12.2 my app is terminated just after startup, with this message in xcode: 在iOS 12.2上,我的应用程序在启动后终止,在xcode中显示此消息:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _alwaysRunsAtForegroundPriority.' 由于未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不是键_alwaysRunsAtForegroundPriority的键值编码兼容。

Anyone who can point me in the right direction for this one? 谁能指出我正确的方向? I see that there has been some warnings about this earlier: 我看到之前有一些警告:

How to resolve app validation "The app references non-public selectors in Payload/MyApp.app/MyApp: _setAlwaysRunsAtForegroundPriority:"? 如何解决应用验证“该应用引用了Payload / MyApp.app / MyApp中的非公共选择器:_setAlwaysRunsAtForegroundPriority:”?

The answer to that post is that it's a security warning from webview that can be ignored. 该帖子的答案是,它是webview的安全警告,可以忽略。 But when it's crashing my app, it can't really be ignored anymore :) 但是当它崩溃我的应用程序时,它不能再被忽略了:)

Thanks in advance for any help. 在此先感谢您的帮助。

Lars 拉尔斯

Update Feb 2nd 2019: It looks like it's the cordova-plugin-background-mode that causes the error. 更新2019年2月2日:看起来它是导致错误的cordova-plugin-background-mode。 But i must admit that i have no idea how to fix that. 但我必须承认,我不知道如何解决这个问题。 It works when i remove that plugin from my project. 当我从我的项目中删除该插件时,它的工作原理。 But i need that plugin, or at least the background-mode functionality, so i need to fix this, somehow. 但我需要这个插件,或者至少是后台模式功能,所以我需要以某种方式解决这个问题。

Update Feb 5th 2019: @coderroggie: I also have the version 2.3.2 of the cordova-plugin-ionic-webview plugin. 更新2019年2月5日: @coderroggie:我还有cordova-plugin-ionic-webview插件的2.3.2版本。 It's strange that it works for me only when removing the cordova-plugin-background-mode (version 0.7.2) 奇怪的是,它仅在删除cordova-plugin-background-mode(版本0.7.2)时适用于我

I'll post my ionic info, if that can provide you with any helpful information. 我会发布我的离子信息,如果它可以为您提供任何有用的信息。

Ionic: 离子型:

ionic (Ionic CLI) : 4.9.0 (/usr/local/lib/node_modules/ionic) 离子(离子CLI):4.9.0(/ usr / local / lib / node_modules / ionic)
Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.1 离子框架:离子角3.9.2 @ ionic / app-scripts:3.2.1

Cordova: 科尔多瓦:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) Cordova Platforms : ios 4.5.5 Cordova Plugins : cordova-plugin-ionic 5.2.9, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.2, (and 22 other plugins) cordova(Cordova CLI):8.1.2(cordova-lib@8.1.1)Cordova平台:ios 4.5.5 Cordova插件:cordova-plugin-ionic 5.2.9,cordova-plugin-ionic-keyboard 2.1.3,cordova- plugin-ionic-webview 2.3.2,(和其他22个插件)

System: 系统:

ios-deploy : 1.9.2 NodeJS : v8.11.1 (/usr/local/bin/node) ios-deploy:1.9.2 NodeJS:v8.11.1(/ usr / local / bin / node)
npm : 6.4.1 OS : macOS Mojave Xcode : Xcode 10.1 Build version 10B61 npm:6.4.1 OS:macOS Mojave Xcode:Xcode 10.1 Build版本10B61

Update Feb 2nd (again) 2月2日更新(再次)

My plugins: 我的插件:

cordova-android-firebase-gradle-release 1.0.2 "cordova-android-firebase-gradle-release" cordova-android-firebase-gradle-release 1.0.2“cordova-android-firebase-gradle-release”
cordova-android-play-services-gradle-release 1.4.3 "cordova-android-play-services-gradle-release" cordova-android-play-services-gradle-release 1.4.3“cordova-android-play-services-gradle-release”
cordova-android-support-gradle-release 1.4.4 "cordova-android-support-gradle-release" cordova-android-support-gradle-release 1.4.4“cordova-android-support-gradle-release”
cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-app-version 0.1.9“AppVersion”
cordova-plugin-background-mode 0.7.2 "BackgroundMode" cordova-plugin-background-mode 0.7.2“BackgroundMode”
cordova-plugin-badge 0.8.7 "Badge" cordova-plugin-badge 0.8.7“徽章”
cordova-plugin-camera 4.0.3 "Camera" cordova-plugin-camera 4.0.3“相机”
cordova-plugin-console 1.1.0 "Console" cordova-plugin-console 1.1.0“控制台”
cordova-plugin-customurlscheme 4.3.0 "Custom URL scheme" cordova-plugin-customurlscheme 4.3.0“自定义URL方案”
cordova-plugin-device 2.0.2 "Device" cordova-plugin-device 2.0.2“设备”
cordova-plugin-file 6.0.1 "File" cordova-plugin-file 6.0.1“文件”
cordova-plugin-file-transfer 1.7.1 "File Transfer" cordova-plugin-file-transfer 1.7.1“文件传输”
cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-geolocation 4.0.1“Geolocation”
cordova-plugin-ionic 5.2.9 "cordova-plugin-ionic" cordova-plugin-ionic 5.2.9“cordova-plugin-ionic”
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-keyboard 2.1.3“cordova-plugin-ionic-keyboard”
cordova-plugin-ionic-webview 2.3.2 "cordova-plugin-ionic-webview" cordova-plugin-ionic-webview 2.3.2“cordova-plugin-ionic-webview”
cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification" cordova-plugin-local-notification 0.9.0-beta.2“LocalNotification”
cordova-plugin-mauron85-background-geolocation 3.0.0-alpha.49 "CDVBackgroundGeolocation" cordova-plugin-mauron85-background-geolocation 3.0.0-alpha.49“CDVBackgroundGeolocation”
cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-network-information 2.0.1“网络信息”
cordova-plugin-safariviewcontroller 1.5.4 "SafariViewController" cordova-plugin-safariviewcontroller 1.5.4“SafariViewController”
cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-splashscreen 5.0.2“Splashscreen”
cordova-plugin-vibration 3.1.0 "Vibration" cordova-plugin-vibration 3.1.0“振动”
cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-plugin-whitelist 1.3.3“白名单”
cordova-support-google-services 1.1.0 "cordova-support-google-services" cordova-support-google-services 1.1.0“cordova-support-google-services”
cordova.plugins.diagnostic 4.0.7 "Diagnostic" cordova.plugins.diagnostic 4.0.7“诊断”
ionic-plugin-keyboard 2.2.1 "Keyboard" ionic-plugin-keyboard 2.2.1“键盘”
phonegap-plugin-push 2.1.3 "PushPlugin" phonegap-plugin-push 2.1.3“PushPlugin”

In the plugin there's a 'setValue' towards the bottom that nukes the app. 在插件中,底部有一个'setValue'来核实应用程序。 Got a build going for 12.2. 得到了12.2的版本。 Try 尝试

ionic cordova plugin add https://github.com/iowayankee/cordova-plugin-background-mode.git

package.json 的package.json

    "cordova-plugin-background-mode": "git+https://github.com/iowayankee/cordova-plugin-background-mode.git",

config.xml config.xml中

    <plugin name="cordova-plugin-background-mode" spec="git+https://github.com/iowayankee/cordova-plugin-background-mode.git" />

Hopefully helps someone at least get the build going 希望能帮助某人至少完成构建

Try this. 尝试这个。 Download plugin cordova-plugin-background-mode or cordova-plugin-better-background-mode in your local folder, attach it to project as a local plugin. 在本地文件夹中下载插件cordova-plugin-background-modecordova-plugin-better-background-mode ,将其作为本地插件附加到项目中。 Go to plugin file src\\ios\\APPBackgroundMode.m and replace following lines 转到插件文件src \\ ios \\ APPBackgroundMode.m并替换以下行

+ (NSString*) wkProperty
{
    NSString* str = @"X2Fsd2F5c1J1bnNBdEZvcmVncm91bmRQcmlvcml0eQ==";
    NSData* data  = [[NSData alloc] initWithBase64EncodedString:str options:0];

    return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}

with

+ (NSString*) wkProperty
{
    NSString* str = @"YWx3YXlzUnVuc0F0Rm9yZWdyb3VuZFByaW9yaXR5";
    NSData* data  = [[NSData alloc] initWithBase64EncodedString:str options:0];

    return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}

To find which of the plugins you use is causing the error run: 要查找您使用的哪个插件导致错误运行:

cd %HOME%/src/myProject    
grep -r "_alwaysRunsAtForegroundPriority" node_modules

Once you find it, look for an upgrade that solves the problem or replace it with an alternate plugin. 找到后,查找解决问题的升级或用备用插件替换它。

In our case, the plugin was WKWebView. 在我们的例子中,插件是WKWebView。 A quick search on google found they had an error and fixed it . 在谷歌上快速搜索发现他们有错误并修复它 We upgraded the plugin and it worked smoothly. 我们升级了插件,它运行顺畅。

I had a similar issue with our ionic 3 app crashing on startup with the iOS beta 12.2. 我的离子3应用程序在iOS beta 12.2启动时遇到了类似的问题。 I also have the latest release of cordova-plugin-background-mode. 我也有最新版本的cordova-plugin-background-mode。

I fixed my issue by upgrading to version 2.3.2 of the cordova-plugin-ionic-webview plug-in. 我通过升级到cordova-plugin-ionic-webview插件的2.3.2版修复了我的问题。

Try that. 试试吧。 If it doesn't fix it, please post your plugins and versions so I can compare. 如果它没有修复它,请发布您的插件和版本,以便我可以比较。

Update Feb 5th, 2019 2019年2月5日更新
I screwed up answering earlier. 我搞砸了早些时候回答。 I'm currently using cordova-plugin-better-background-mode@0.7.5 which is a fork of cordova-plugin-background-mode@0.7.2 . 我目前使用cordova-plugin-better-background-mode@0.7.5这是一个叉cordova-plugin-background-mode@0.7.2

Try switching to that one. 尝试切换到那个。 If that doesn't work I'll post the rest of the differences that we might have. 如果这不起作用,我会发布我们可能有的其他差异。

I think your basic issue is you're running in a WKWebView, which isn't allowed to run in the background reliably. 我认为你的基本问题是你在WKWebView中运行,不允许在后台可靠地运行。 I'm facing a similar issue, and I'm afraid the best short-term solution I could come up with was to use UIWebView. 我面临着类似的问题,我担心我能提出的最好的短期解决方案是使用UIWebView。 UIWebView isn't a good long-term solution because it's marked as deprecated now. UIWebView不是一个好的长期解决方案,因为它现在被标记为已弃用。 It looks like you're not using Ionic 4 yet, which is really good in this case. 看起来你还没有使用Ionic 4,这在这种情况下确实很好。 I think you can remove the 2 ionic plugins, use cordova@6.5.0 and cordova engine ios 4.5.4. 我想你可以删除2个离子插件,使用cordova@6.5.0和cordova引擎ios 4.5.4。 Hopefully, then, when running in Xcode, everything will work and you'll see a message towards the beginning about "Using UIWebView". 希望,当在Xcode中运行时,一切都会正常工作,你会看到一条关于“使用UIWebView”的消息。 This issue is part of the evidence I've found that WKWebView isn't expected to work in the background: https://issues.apache.org/jira/browse/CB-10657 https://issues.apache.org/jira/browse/CB-11561 这个问题是我发现WKWebView不会在后台运行的证据的一部分: https //issues.apache.org/jira/browse/CB-10657 https://issues.apache.org/ JIRA /浏览/ CB-11561

这对我有帮助:“部署信息主界面必须为空”来源: https//forum.ionicframework.com/t/app-crashes-when-i-try-to-open-in-it-on-tesflight-on -a-iphone /3分之21005

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM