Unable to disable new architecture in iOS

This issue has been tracked since 2022-09-19.

Description

I have recently enabled new architecture in iOS by running following command

RCT_NEW_ARCH_ENABLED=1 pod install

I would like to disable new architecture now, But unable to figure out a way. I couldn't find anything from official documentation as well.

Is there anyway to disable the new architecture or creating the new project is the only way?

Thank You.

Version

0.69.5

Output of npx react-native info

System:
     OS: macOS 12.5
     CPU: (8) x64 Apple M1
     Memory: 24.20 MB / 8.00 GB
     Shell: 5.8.1 - /bin/zsh
Binaries:
     Node: 14.0.0 - /usr/local/bin/node
     Yarn: Not Found
      npm: 6.14.4 - /usr/local/bin/npm
      Watchman: Not Found
 Managers:
       CocoaPods: 1.11.2 - /opt/homebrew/bin/pod
 SDKs:
       iOS SDK:
       Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
 Android SDK: Not Found
 IDEs:
        Android Studio: 4.2 AI-202.7660.26.42.7351085
        Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
 Languages:
        Java: 11.0.10 - /usr/bin/javac
 npmPackages:
        @react-native-community/cli: Not Found
        react: Not Found
        react-native: Not Found
        react-native-macos: Not Found
        npmGlobalPackages:
         *react-native*: Not Found

Steps to reproduce

Since it is not any error I cannot provide any reproducible steps. I am just looking for a way to disable the new architecture in iOS.

Snack, code example, screenshot, or link to a repository

I do not have any code snippet since I am not facing any errors.

cortinico wrote this answer on 2022-09-20

I would like to disable new architecture now, But unable to figure out a way. I couldn't find anything from official documentation as well.
Is there anyway to disable the new architecture or creating the new project is the only way?

If you run RCT_NEW_ARCH_ENABLED=0 pod install you'll be effectively disabling the New Architecture.

Yandamuri wrote this answer on 2022-09-21

I would like to disable new architecture now, But unable to figure out a way. I couldn't find anything from official documentation as well.
Is there anyway to disable the new architecture or creating the new project is the only way?

If you run RCT_NEW_ARCH_ENABLED=0 pod install you'll be effectively disabling the New Architecture.

@cortinico This solution doesn't seem like working.

Let me explain what's happening in my app,

I ran RCT_NEW_ARCH_ENABLED=1 pod install and pod installation was successful. When I ran app from Xcode faced the following error,

 `react/renderer/components/view/ViewEventEmitter.h' file not found 

This error is coming from following file,

 ios/Pods/Headers/Private/React-Codegen/react/renderer/components/rncore/EventEmitters.h 

it's looking for a file which supposed to be in the following location,

 ios/Pods/Headers/Private/React-Codegen/react/renderer/components/view/ViewEventEmitter.h

But in fact, This file doesn't exist in the above path.

RCT_NEW_ARCH_ENABLED=1 pod install command resulted in creating a folder called react(this folder contains the path of file where error is occurring) react/renderer/components/view/ViewEventEmitter.h) which was not there before enabling the new architecture.

Though I ran RCT_NEW_ARCH_ENABLED=0 pod install, still react folder is there, So does error.

What should I do now to get rid of this error?

cipolleschi wrote this answer on 2022-09-21

Hi @Yandamuri, thanks for opening the issue and I'm sorry you are incurring into it.

Could you try to:

  1. navigate to the ios folder of your project
  2. remove the build folder
  3. run pod install
    And see if it fixes the issue?

It looks like that your build folder kept some dirty files from the previous build.
Let me know if it works!

Yandamuri wrote this answer on 2022-09-21

@cipolleschi This is great. Thank you so much. Issue got resolved.

I am just asking out of curiosity, Do you have any idea about why the ViewEventEmitter.h isn't there(Which explained in my above comment) when I ran RCT_NEW_ARCH_ENABLED=1 pod install?

cipolleschi wrote this answer on 2022-09-21

When running RCT_NEW_ARCH_ENABLED=1 pod install, we are also running a bit of Codegen to generate some files in the React-Codegen local pod. In the old architecture, we run a similar Codegen (actually the same code) but from a different entry points and with slightly different parameters.

I have not explored in depth why this error occur. My guess is that the two Codegen processes generate file in slightly different way. Furthermore, Cocoapods could have some cache heuristic which fails to pick up the differences and it could be that it doesn't update the dependencies correctly.

Yandamuri wrote this answer on 2022-09-22

@cipolleschi

Surprisingly The mentioned error gone now, In Fact, the new react folder(ios/Pods/Headers/Private/React-Codegen/react) hasn't been created now. But When I ran RCT_NEW_ARCH_ENABLED=1 pod install faced following error,

 error: Could not determine react-native-codegen location. Try running 'yarn install' or 'npm install' in your project root.

Then I installed react-native-codegen and then ran RCT_NEW_ARCH_ENABLED=1 pod install. Then pod installation was successful.

Is react-native-codegen mandatory to enable new architecture?

cipolleschi wrote this answer on 2022-09-22

react-native-codegen is indeed required by the New Architecture. It is a package within React Native, therefore, when you install React Native, it will pull also that package automatically.

From the error message, it seems like React Native did not install itself correctly. Rather than explicitly install react-native-codegen package, could you please try to just run yarn install and see if the error disappear?

Yandamuri wrote this answer on 2022-09-23

@cipolleschi Yes you are right. After npm install issue got resolved.

Thank you for your support.

More Details About Repo
Owner Name facebook
Repo Name react-native
Full Name facebook/react-native
Language JavaScript
Created Date 2015-01-09
Updated Date 2022-10-03
Star Count 105144
Watcher Count 3666
Fork Count 22469
Issue Count 2232

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date