upgrade-support icon indicating copy to clipboard operation
upgrade-support copied to clipboard

Where/how to set ENV values on Podfile on 0.71.0?

Open Adnan-Bacic opened this issue 2 years ago • 3 comments

Environment

System:
    OS: macOS 13.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 40.85 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 3.2.0 - /usr/local/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
    Watchman: 2021.10.18.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 23, 28, 29, 30, 31, 32, 33
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0
      System Images: android-29 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64, android-32 | Google APIs Intel x86 Atom_64, android-33 | Google APIs Intel x86 Atom_64, android-33 | Google Play Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9477386
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.14.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.0 => 0.71.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Things I’ve done to figure out my issue

  • [ X ] I used upgrade-helper to do my upgrade.
  • [ X ] I searched in the project code for NO_FLIPPER, and the only result is from the Podfile itself

Upgrading version

From 0.70.6 to 0.71.0 - https://react-native-community.github.io/upgrade-helper/?from=0.70.6&to=0.71.0

Description

i feel like this is a continuation of this issue: https://github.com/react-native-community/upgrade-support/issues/193, as it is very similar.

for example, the new Podfile syntax uses an ENV variable called NO_FLIPPER to enable/disable flipper. but where can we see/set this variable for our environment? i cant see a way where we can see the env value of this variable or change it.

looks like this:

flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

i thought maybe it was in .xcode.env, but a comment in the original thead: https://github.com/react-native-community/upgrade-support/issues/193#issuecomment-1125065823 says this is mainly used for Node.

Reproducible demo

Adnan-Bacic avatar Jan 23 '23 13:01 Adnan-Bacic

I think this variable is more used for the CI/CD, when you are running your jobs you can pass env variables. So if you build your production builds in CI, you can pass NO_FLIPPER and it will disable flipper for production, but keeps it enabled for your local builds and development.

You can set your env variable inline for example NO_FLIPPER=1 pod install command will run pod install with flipper disabled.

I suggest to remove react-native-flipper if you're not using it for both platforms. But if you want to disable it just for iOS then you can set flipper_config = FlipperConfiguration.disabled in your Podfile. And modify your react-native.config.js to not load react-native-flipper dependancy on iOS.

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-flipper': { platforms: { ios: null } },
  },
};

alarm109 avatar Mar 14 '23 14:03 alarm109

that may be a solution to do it in react-native.config, but it still doesnt answer how we can do it the "real" way

but we still dont know how it works. does it read from .env in the root of the project? in the ios folder? what if we have multiple .env files?

Adnan-Bacic avatar Mar 14 '23 19:03 Adnan-Bacic

Well you could easily test it out by creating .env files. But to answer your question, it reads from your shell config file. You can set your shell env variables inside ~/.zshrc, assuming you're using zsh. So if you add export NO_FLIPPER=1 to your ~/.zshrc and run source ~/.zshrc. Then running pod install you'll see that flipper is disabled. But I think this is not the inteded way of using it. If you're not trying to disable flipper while building your app, you should ignore the env variable and just make it disabled always, by flipper_config = FlipperConfiguration.disabled.

This way of disabling flipper is clearly setup for disable it for the CI builds by passing a variable, while building. And this makes sense, because it should reduce build times and you don't need flipper in production.

alarm109 avatar Mar 14 '23 22:03 alarm109