react-native-community / upgrade-support

A central community-backed place to request and give help when upgrading your app.
MIT License
261 stars 2 forks source link

Where/how to set flags on Podfile on 0.68.0? #193

Open efstathiosntonas opened 2 years ago

efstathiosntonas commented 2 years ago

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?

dev-ylyl commented 2 years ago

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

usmankhan495 commented 2 years ago

fabric_enabled=1 hermes_enabled=1 RCT_NEW_ARCH_ENABLED=1 pod install

this will enable Hermes and fabric.

fukemy commented 2 years ago

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

bimusiek commented 2 years ago

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.

fukemy commented 2 years ago

thanks, i removed flag then it's work.

eliaslecomte commented 2 years ago

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

Adnan-Bacic commented 2 years ago

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 commented 2 years ago

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.

leotm commented 2 years ago

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

lelukas commented 2 years ago

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, changefalsetotrueand then install pods

replace with

# to enable hermes on iOS, changeflags[:hermes_enabled]totrueand then install pods

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

nujhong commented 2 years ago

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:

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

Yandamuri commented 1 year ago

@efstathiosntonas

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