Skip to main content

Building Production Apps | Cordova Document Scanner

iOS

The Scanbot SDK iOS Framework (included in this Cordova Plugin) contains the most used architectures (arm64, armv7, x86_64, i386). You can thus run it on most iOS devices as well as on simulators during the development phase. To be able to submit a production build to the App Store or a test build for TestFlight you have to remove (strip away) the architectures x86_64 and i386 from the Scanbot SDK Framework. These architectures are only for simulators and are not allowed to be submitted to iTunes Connect.

We provide a script for that, which can be found in:

plugins/cordova-plugin-scanbot-sdk/src/ios/Frameworks/ScanbotSDK.framework/strip-SBSDK-Framework.sh

This script removes the unnecessary architectures from the frameworks binary, code signs the framework and adds the crash symbols (dSYM) file to your app's archive. The final package size (IPA) of your app will then be significantly smaller than a debug version used during the development phase.

To add this script in your build process, you need to apply a few changes in the Xcode project:

  1. Open the generated Xcode project file with Xcode IDE: <YOUR_APP_PROJECT_PATH>/platforms/ios/<YOUR_APP_NAME>.xcodeproj
  2. Go to TARGETS settings and open the tab Build Phases. Add a new Run Script Phase and make sure this phase is below the Embed Frameworks build phase.
  3. Adjust this Run Script Phase with the following script data:

Script code:

bash "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/ScanbotSDK.framework/strip-SBSDK-Framework.sh"

Script Input File:

$(SRCROOT)/../../plugins/cordova-plugin-scanbot-sdk/src/ios/Frameworks/dSYMs/ScanbotSDK.framework.dSYM

alt text

Android

The Scanbot Android SDK uses native libraries under the hood and supports the following ABIs: armeabi-v7a, arm64-v8a, x86 and x86_64.

By default the native libraries of all these architectures will be included in the app package (APK), which will result in a big APK file. Please consider removing support for x86 and x86_64 architectures. In most cases both "x86" architectures can be removed for the release (production) build, since they are only used on emulators and on some rare devices with the Intel Atom architecture.

To exclude certain ABIs from the APK, use the abiFilters property in the Android Gradle settings of your project. To apply any custom Gradle settings on a Cordova generated Android project, create the additional custom .gradle file with the name

platforms/android/app/build-extras.gradle

and define your custom Gradle settings in it. In this case we define abiFilters to exclude x86 and x86_64 architectures:

ext.postBuildExtras = {
android.defaultConfig.ndk.abiFilters = ["armeabi-v7a", "arm64-v8a"]
}

💡 However, if you need to support all architectures and to optimize the APK size, we highly recommend checking out the Android App Bundle approach. It allows you to create and distribute dedicated and smaller APKs via the PlayStore (basically it is similar to the iOS App Store approach).

License Check

If your Scanbot SDK license has expired, any call of the Scanbot SDK API will result in an error. To prevent this you should always check for license expiration during the runtime by calling and checking the result of the API method getLicenseInfo(). If the result result.info.isLicenseValid is false, you should disable any usage of the Scanbot SDK functions or UI components in your app.

info

We highly recommend implementing a suitable handling of this case in your app!

const result = await this.SDK.getLicenseInfo();
if (result.info.isLicenseValid) {
// OK, we have a valid license. Making the calls of the Scanbot SDK plugin API is now safe.
// E.g. launch the Document Scanner UI
// this.SDK.UI.startDocumentScanner(...)
} else {
// Implement a suitable handling (e.g. disable Scanbot functionality in your app)
alert('Scanbot SDK license is not valid!');
}

Result fields:

  • result.info.isLicenseValid: boolean - Whether the license is valid or not.
  • result.info.licenseStatus: LicenseStatus - Status of the license as LicenseStatus enum. See enum values and description below.
  • result.info.licenseExpirationDate?: number - Optional expiration date of the license.

LicenseStatus enum values:

  • LicenseStatus.Okay - License is valid.
  • LicenseStatus.Trial - No license installed, trial mode is active.
  • LicenseStatus.Expired - License error: License has expired.
  • LicenseStatus.WrongOS - License error: License does not include support for current operating system.
  • LicenseStatus.Corrupted - License error: License key string is invalid or corrupted. Please check the format of the string.
  • LicenseStatus.AppIDMismatch - License error: License does not include the Bundle ID or Application ID of this app.
  • LicenseStatus.NotSet - License error: No license installed (e.g. when trial mode is over).
  • LicenseStatus.Unknown - Unknown license status. Please contact support.

Want to scan longer than one minute?

Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?


On this page

Scroll to top