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 disable the metro minifier, since Jscrambler itself is capable of minifying code. At metro.config.js, add or modify the existing exports to include the following:

module.exports = {
  transformer: {
    minifierPath: require("path").resolve("./dummy-minification"),
  },
};

Additionally, create a dummy-minification.js file at the root of the project with the following:

module.exports = {
  withSourceMap: (code, map, filename, options) => ({ code, map }),
};

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.