Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
efstathiosntonas opened this issue Mar 31, 2022 · 12 comments
Open
1 task done

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

efstathiosntonas opened this issue Mar 31, 2022 · 12 comments

Comments

@efstathiosntonas
Copy link

efstathiosntonas commented Mar 31, 2022

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 efstathiosntonas changed the title Where to set flags on Podfile on 0.68.0? Where/how to set flags on Podfile on 0.68.0? Mar 31, 2022
@dev-ylyl
Copy link

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

@usmankhan495
Copy link

usmankhan495 commented Apr 13, 2022

fabric_enabled=1 hermes_enabled=1 RCT_NEW_ARCH_ENABLED=1 pod install

this will enable Hermes and fabric.

@fukemy
Copy link

fukemy commented Apr 14, 2022

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

@bimusiek
Copy link

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
Copy link

fukemy commented Apr 14, 2022

thanks, i removed flag then it's work.

@eliaslecomte
Copy link

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

@Adnan-Bacic
Copy link

Adnan-Bacic commented May 2, 2022

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
Copy link

Adnan-Bacic commented May 12, 2022

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

and a pr was made by someone from the react-native team: facebook/react-native-website#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
Copy link

leotm commented May 12, 2022

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
Copy link

lelukas commented Jun 10, 2022

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

@nujhong
Copy link

nujhong commented Jun 17, 2022

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

@Yandamuri
Copy link

Yandamuri commented Jul 27, 2023

@efstathiosntonas

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests