How to add sourcemap in React Native for Production?

后端 未结 4 535
旧时难觅i
旧时难觅i 2020-12-04 18:05

I received error log like the following while the app crashed:

Fatal Exception: com.facebook.react.modules.core.JavascriptException: onSelect index.

4条回答
  •  萌比男神i
    2020-12-04 18:31

    Android inspired by @chetstone's answer

    Starting on v0.32 for android, you can modify your android/app/build.gradle to accomplish this. Look for the line

    apply from: "../../node_modules/react-native/react.gradle"

    Just above this, you will see something like:

    project.ext.react = [
        entryFile: "index.js",
    ]
    

    Modify it to match the following

    project.ext.react = [
        entryFile: "index.js",
        extraPackagerArgs: ["--sourcemap-output", file("$buildDir/../../../sourcemap.android.js")]
    ]
    

    On iOS

    Go to your build phases in Xcode for the "Bundle React Native code and images" phase and add:

    export EXTRA_PACKAGER_ARGS="--sourcemap-output sourcemap.ios.js"
    

提交回复
热议问题