3

I created a new React Native app using the CLI with the boilerplate template. The resulting iOS app size in release mode is unexpectedly large: 511.9 MB. Normally I would expect a new React Native app to be less than 10 MB. This large app size seems to be a recent change. What am I not considering? Thanks in advance!

Steps taken:

  1. npm uninstall -g react-native-cli @react-native-community/cli
  2. npx react-native@latest init TestProject
  3. Open /ios/TestProject.xcworkspace in Xcode
  4. Go to Test Project > Edit Scheme
  5. Change build configuration to Release and uncheck Debug Executable
  6. Close popup window
  7. Push run button to run the app on my connected device
  8. On the iPhone, check Settings > General > iPhone Storage
  9. The newly installed app shows that it is using 511.9 MB of space

Other steps I tried:

  1. In XCode, click Product > Archive.
  2. In the Organizer window, right-click the app and click Show in Finder
  3. The resulting app size on the file system is 544.8 MB

My environment:

  • macOS: Ventura 13.2.1
  • Xcode: 14.2 (14C18)
  • Node: 18.15.0
  • Ruby: 2.7.6p219

Project package.json (from the boilerplate template)

{
  "name": "TestProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.71.4"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native-community/eslint-config": "^3.2.0",
    "@tsconfig/react-native": "^2.0.2",
    "@types/jest": "^29.2.1",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.73.8",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "jest": {
    "preset": "react-native"
  }
}
Anthony Tietjen
  • 1,032
  • 2
  • 8
  • 19
  • in the release mode, have you enabled bit code while running/creating the build? What is the size of the build when debug mode is enabled? – Gavara.Suneel Mar 15 '23 at 05:13
  • May be this solution would help you in the release mode(which suggests to enable bit code) `https://stackoverflow.com/a/68661895/8988448` – Gavara.Suneel Mar 15 '23 at 05:45
  • 1
    @Gavara.Suneel After enabling bitcode, then running Archive, the archive fails and shows this error: libCocoaAsyncSocket.a(GCDAsyncSocket.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. – Anthony Tietjen Mar 15 '23 at 05:57
  • This means that `libCocoaAsyncSocket.a` was not compiled with bit code. Could you clean & build again? – Gavara.Suneel Mar 15 '23 at 06:10
  • @Gavara.Suneel How to do that when that is not our library? – Steve Moretz Jul 03 '23 at 08:58

0 Answers0