Troubleshooting my builds

This page will cover known limitations and workarounds to have a smooth experience.

Code is not protected in Debug mode

Problem

React-native (>= 0.6) uses Metro build server to help on development. However, it has some limitations that prevents us from protecting your source code in debug mode. (executing react-native start or react-native run-android will start the app in debug mode).

Solution

Be sure to make your builds as release. Check Integration section for more details.

Custom Callbacks may not be triggered

Problem

Due to the way our plugin hooks itself on the metro build process, there could be the case where your custom callback is not called at runtime. This can happen, for example, due to it not being declared when it's trying to be used.

Solution

Be sure that custom callbacks are placed on the project's entry file (usually, index.js file), attached to the window global object:

window.myCustomCallback = () => {
  alert("Custom Callback called!");
};

// Your Code

On top of this, make sure to test all your callbacks before shipping your App. Check Integration section for more details on how to run your App in an emulated environment.

Some or all of my annotations are not working

Problem

Metro removes all comments before Jscrambler has even a chance of processing the code (this can be turned off but due to a Metro Configuration issue, it is not possible at this time).

Solution

You should use string annotations.

However, this may be insufficient, as the minifier used by Metro also removes strings that appear to be unused (Dead Code), meaning that only string annotations that appear at the top of each function or file are preserved. The solution is to change the config of the metro minifier. At metro.config.js, add or modify the existing file to include the following:

const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

const jscramblerMetroPlugin = require("jscrambler-metro-plugin")();

const config = {
  // if you have other metro configs, add here
  ...jscramblerMetroPlugin,
  transformer: {
    minifierConfig: {
      output: {
        comments: /@jscrambler/
      }
    }
  }
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);

Metro should now preserve string annotations.

OS Lock doesn't work with Mobile OS (Android/IOS)

Problem

React-Native by default, don't expose a global API to get information about the Operating System and Device. Due to that osLock will not work under this framework.

Solution

We have no workaround for this at the moment.

Metro is generating source maps that won't be useful after Jscrambler protection

Problem

Some React-Native applications might have source-map generation feature activated through the --sourcemap-output option. The jscrambler-metro-plugin is aware of this React-Native argument and instructs our protection engine to produce source-maps for the obfuscated code.

However, the Jscrambler Source-Maps feature is only available for Enterprise customers. All the other plans will end up with the following build error:

Metro is generating source maps that won't be useful after Jscrambler protection.
  If this is not a problem, you can either:
    1) Disable source maps in metro bundler
    2) Explicitly disable Jscrambler source maps by adding 'sourceMaps: false' in the Jscrambler config file

  If you want valid source maps, make sure you have access to the feature and enable it in Jscrambler config file by adding 'sourceMaps: true'

Solution

There are two possible solutions:

  • If source-maps are not important, you can disable them either:
    • on React-Native build command removing --sourcemap-output option;
    • or adding sourceMaps: false in the Jscrambler Configuration.
  • If source-maps are important, you can contact our sales/support team and upgrade your Jscrambler account.

Application breaks on Hermes Engine

Problem

Hermes is an open-source JavaScript engine optimized for React Native. Some of those optimizations cause a mal-function on the following transformations:

Your application will most likely break when you select one of the above transformations.

Solution

We have no workaround for this at the moment, therefore you shouldn't include the incompatible transformations on your jscrambler.json file. For Code Hardening security layer, you have to set the following option, making sure that no source file will be able to include it:

{
  ...
  "codeHardeningThreshold": "104857600",
  ...
}