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

Where/how to set flags on Podfile on 0.68.0?

Open efstathiosntonas opened this issue 3 years ago • 12 comments

Environment

not possible to get environment info, I'm using a yarn monorepo.

Things I’ve done to figure out my issue

Upgrading version

0.67.3 to 0.68.0

Description

According to upgrade-helper we must make these changes on Podfile

 # Flags change depending on the env values.
  flags = get_default_flags()

    use_react_native!(
      :path => config[:reactNativePath],
      # to enable hermes on iOS, change `false` to `true` and then install pods
      :hermes_enabled => flags[:hermes_enabled],
     :fabric_enabled => flags[:fabric_enabled],
     # An absolute path to your application root.
     :app_path => "#{Pod::Config.instance.installation_root}/.."
    )

Question is, how we set these flags? After running pod install hermes is removed since the default value for hermes_enabled is false(?). Is there a step missing on upgrade-helper?

efstathiosntonas avatar Mar 31 '22 06:03 efstathiosntonas

Hi , You can try this command. RCT_NEW_ARCH_ENABLED=1 pod install

dev-ylyl avatar Apr 11 '22 13:04 dev-ylyl

fabric_enabled=1 hermes_enabled=1 RCT_NEW_ARCH_ENABLED=1 pod install

this will enable Hermes and fabric.

usmankhan495 avatar Apr 13 '22 08:04 usmankhan495

i got this error: Invalid Podfile file: undefined method `get_default_flags' please help

fukemy avatar Apr 14 '22 05:04 fukemy

Hey, you can just not use flags? I mean, these are changes so impactful that I don't see a need to use flags here, just set it manually to either true or false a no bothering if your flag is passed from CLI.

Looks cleaner than having some hermes_enabled=1 around CLI scripts or yarn scripts.

bimusiek avatar Apr 14 '22 16:04 bimusiek

thanks, i removed flag then it's work.

fukemy avatar Apr 14 '22 17:04 fukemy

What about when using fastlane; https://docs.fastlane.tools/actions/cocoapods/

eliaslecomte avatar Apr 19 '22 08:04 eliaslecomte

i think it may be included i react-native 0.69. there is a rc release available on react-native-upgrade-helper:

https://react-native-community.github.io/upgrade-helper/?from=0.68.1&to=0.69.0-rc.0

there is a new _xcode.env file which i think is where you set the flags. this is just speculation but it seems like it could be the place you define these flags. though it would still be nice with some official confirmation.

though this file has no hermes_enabled and fabric_enabled variables, so it may not be it.

edit:

i just tried adding the _xcode.env file to a project and adding

export hermes_enabled=true

at the bottom, to see if it enables hermes. hermes is still false for me.

i also tried to add

hermes_enabled=true

to me .env file. still false

Adnan-Bacic avatar May 02 '22 11:05 Adnan-Bacic

maybe someone has already seen it, but i posted in the react-native repo asking for clarification: https://github.com/facebook/react-native-website/issues/3105

and a pr was made by someone from the react-native team: https://github.com/facebook/react-native-website/pull/3109

so basically, it seems the default flags are just that, default values. if you want to change the value you dont have to edit the flag values anywhere, you just write true/false directly in the Podfile.

so i believe that closes this issue.

Adnan-Bacic avatar May 12 '22 08:05 Adnan-Bacic

you're right @efstathiosntonas this has caused some confusion and thanks @Adnan-Bacic for raising again / updating us 👍

we've just recently added to the template and website

# By default, Hermes is disabled on Old Architecture, and enabled on New Architecture. # You can enabled/disable it manually by replacing flags[:hermes_enabled] with true or false.

where 0.68 adds/sets the below internally (not in 0.67.0)

# 0.68-stable: react-native/scripts/react_native_pods.rb
def get_default_flags()
  flags = {
    :fabric_enabled => false,
    :hermes_enabled => false,
  }
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
    flags[:fabric_enabled] = true
    flags[:hermes_enabled] = true
  end
  return flags
end
# GitHub doesn't format permalink markdown to other repos
# So here's the snippet above

so RCT_NEW_ARCH_ENABLED being our new 0.68+ environment variable set via RCT_NEW_ARCH_ENABLED=1 pod install (or unofficially via Podfile)

and our new .xcode.env just let's us config other/more environment-related things, like which NODE_BINARY (node PATH) to use

leotm avatar May 12 '22 14:05 leotm

In the podfile, a better comment explaining how to enable hermes could also help to clarify this confussion.

Instead of

# to enable hermes on iOS, change falsetotrue and then install pods

replace with

# to enable hermes on iOS, change flags[:hermes_enabled]totrue and then install pods

Or maybe another line stating that flags are just static flags and can be replaced by booleans

lelukas avatar Jun 10 '22 17:06 lelukas

Just dug into the source code https://github.com/facebook/react-native/blob/v0.69.0-rc.6/scripts/react_native_pods.rb#L135, the correct way to enable ~~hermes or~~ fabric is either:

  • ~~set export USE_HERMES=true in .xcode.env~~ (evaluation of this var is no longer available)
  • set export RCT_NEW_ARCH_ENABLED=true in .xcode.env
  • Set the same environment variable at build time in other means

Of course you can replace :hermes_enabled => flags[:hermes_enabled] with :hermes_enabled => true if you only want to enable Hermes but not ready for Fabric

nujhong avatar Jun 17 '22 01:06 nujhong

@efstathiosntonas

BTW, what is reactNativePath in the line :path => config[:reactNativePath] ? (In earlier RN versions it used to be string literal)

Yandamuri avatar Jul 27 '23 11:07 Yandamuri