问题
Cordova v5.3.1 / Ionic v1.1.0 (library v1.6.4)
Upgraded our application to iOS 9 from 8.4. The application builds and runs fine on iPad/iPad mini. However, it crashes when deployed to an iPhone.
Below is the debug output:
2015-09-23 11:17:09.920 AnApplicaiton[6490:1359695] *** Assertion failure in -[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:1697
2015-09-23 11:17:09.926 AnApplication[6490:1359695] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread'
The debug console is identical up to this point.
回答1:
I don't know the real reason but when the App has WebView and third party keyboard such as Swype, program crashes. I replicated the issue many times. So if your app uses WebView such as Cordova, iAd, Admob you will see these weird crashes. I don't know how to prevent this issue. It only happens on iOS and only on iPhones. My crash reports show iPhone 5s, iPhone 6, iPhone 6 Plus.
Edit: I think code given by @Kurt.F can fix the issue for now. Add following code to your AppDelegate.swift
file. All credits go to @Kurt.F
func application(application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: String) -> Bool {
if extensionPointIdentifier == UIApplicationKeyboardExtensionPointIdentifier {
return false
}
return true
}
回答2:
This seems to be a conflict between 3rd party keyboards and the WebView. I am also able to crash Chrome (outside of Cordova) on iOS 9. I just go to a popular website and focus on some edit fields a few times. You can do his while the page is loading to bring out the keyboard while a certain custom one is enabled and it crashes.
I created a simple Cordova plugin to not allow any keyboard extensions to run with the app. Not a permanent solution, but it will stop the crashes for now. Just add the plugin, no code changes are needed.
https://github.com/kurtisf/cordova-plugin-restrict-keyboard
来源:https://stackoverflow.com/questions/32744781/ios-9-ionic-cordova-app-crashes-on-iphone-works-on-ipad