简体   繁体   English

从 APK 和 IPA 应用程序(React Native 和/或 Expo)中删除 Javascript Bundle

[英]Remove Javascript Bundle from APK and IPA apps (React Native and/or Expo)

After building the APK of my React native app, I realized that the APK could be opened just like an archive and that there was inside of it a file named index.android.bundle which is the JavaScript bundle of the React Native app!在构建我的 React Native 应用程序的 APK 后,我意识到 APK 可以像存档一样打开,并且里面有一个名为index.android.bundle的文件,它是 React Native 应用程序的 JavaScript 包!

I don't understand why this file has been included there since the Android app works with compiled .dex files.我不明白为什么这个文件被包含在那里,因为 Android 应用程序使用编译的.dex文件。

My question我的问题

  • Is there a way to make sure this file (JS bundle) is not included in the final application (APK for android and IPA for iOS) when creating it using either React Native or Expo?在使用 React Native 或 Expo 创建最终应用程序(android 的 APK 和 iOS 的 IPA)时,有没有办法确保该文件(JS 包)不包含在最终应用程序中?

there is no way of not including the JS bundle in a react native app.没有办法不在 React Native 应用程序中包含 JS 包。

React native relies on that index.android.bundle , on android for example, in order to load your code. React native 依赖于index.android.bundle ,例如 android 来加载你的代码。 Basically all the JS that you've developed is inside these files and that's the main concept of React native.基本上你开发的所有 JS 都在这些文件中,这是 React native 的主要概念。

A react native project is a regular native project (iOS or Android), that has a special view inside, on Android it's called ReactRootView and on iOS RCTRootView , these views are responsible for loading your JS bundle, in your case index.android.bundle , and then they communicate across the JS bridge in order to instantiate views and components. React Native 项目是一个常规的本机项目(iOS 或 Android),内部有一个特殊的视图,在 Android 上称为ReactRootView ,在 iOS RCTRootView上,这些视图负责加载你的 JS 包,在你的例子中index.android.bundle ,然后它们通过 JS 桥进行通信以实例化视图和组件。

I'll link you some articles explaining in more details how react native works and what's the concept of a JS bridge我会链接一些文章给你,更详细地解释 react native 是如何工作的以及 JS 桥的概念是什么

https://hackernoon.com/understanding-react-native-bridge-concept-e9526066ddb8 https://formidable.com/blog/2019/react-codegen-part-1/ https://hackernoon.com/understanding-react-native-bridge-concept-e9526066ddb8 https://formidable.com/blog/2019/react-codegen-part-1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM