As discussed in a previous blog, a critical step to take in preparing your apps for version 200 is to replace deprecated APIs with current APIs and contemporary code. This blog describes how to do this in QML.
Because QML is an interpreted language, it does not currently have a compiler, linter, or IDE tools to help you easily identify deprecated API usage. As such, we’ve introduced a property on ArcGISRuntimeEnvironment named logDeprecatedWarnings. This property logs to the console whenever a deprecated class, property, method, or signal is used in your app. The log content contains the API name that is deprecated, as well as the file and line number in some circumstances.
After identifying deprecated API usage, consult the API reference doc to find a suitable replacement and make appropriate changes to your code.
Please note that these warnings are run-time warnings, not compile-time warnings. This means the warnings will be logged throughout the lifetime of running your apps. Thus, it is important to fully test your app to ensure all code paths are run. Some common potential pitfalls include:
- QML files or Components that are loaded with a QML Loader, StackView, or other similar pattern. The QML engine will not parse these files or components until they are loaded, so it is essential that your app testing loads all QML files and code.
- JavaScript code is not parsed by the QML engine when the file is loaded, but rather when the JavaScript code is run. For example, in this case the warning will be logged when the button is clicked.
This property is enabled by default. It can be disabled by setting the property to false.