react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.28k stars 890 forks source link

`react-native.config.js` doesn't override `project`properties #2441

Open blakef opened 4 days ago

blakef commented 4 days ago

Environment

info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (10) arm64 Apple M1 Pro
  Memory: 317.25 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.12.0
    path: ~/Library/Caches/fnm_multishells/1944_1719845764196/bin/node
  Yarn:
    version: 1.18.0
    path: xxx
  npm:
    version: 10.5.0
    path: ~/Library/Caches/fnm_multishells/1944_1719845764196/bin/npm
  Watchman:
    version: 2024-06-28T02:56:23Z
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/blakef/.gem/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "33"
      - "34"
    Build Tools:
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
      - 35.0.0
    System Images:
      - android-31 | Google Play ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google APIs Intel x86_64 Atom
      - android-34 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /Users/blakef/.jenv/shims/javac
  Ruby:
    version: 2.7.8
    path: /Users/blakef/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

info React Native v0.74.3 is now available (your project is running on v0.74.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.74.3
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.74.2
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".

Description

If there is a react-native.config.js file in the project root, the project properties are largely ignored. For example:

CleanShot 2024-07-02 at 10 58 56@2x

I'd expect (maybe incorrectly), the user defined react-native.config.js to override any defaults. You can see it's partially applied with reactNativePath but not in the platform.

Reproducible Demo

https://github.com/blakef/community-cli-repro

szymonrybczak commented 4 days ago

What would be the use-case of this since under SomethingSourceDir there's no Podfile?

If you run in your repro example mv ios SomethingSourceDir, then everything is working fine:

  "project": {
    "ios": {
      "sourceDir": "/Users/szymonrybczak/development/tmp/community-cli-repro/SomethingSourceDir",
      "xcodeProject": {
        "name": "Example.xcodeproj",
        "path": ".",
        "isWorkspace": false
      },
      "automaticPodsInstallation": false,
      "assets": []
    },
    "android": {
      "sourceDir": "/Users/szymonrybczak/development/tmp/community-cli-repro/android",
      "appName": "app",
      "packageName": "com.example",
      "applicationId": "com.example",
      "mainActivity": ".MainActivity",
      "assets": []
    }
  }