facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.33k stars 24.23k forks source link

[IOS] hermes.h and LongLivedObject.h errors #34238

Closed ahmadzraiq closed 2 years ago

ahmadzraiq commented 2 years ago

Description

After enabling the new architecture on IOS I got Hermes.h exception

package.json { "main": "index.js", "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "postinstall": "patch-package" }, "dependencies": { "@codler/react-native-keyboard-aware-scroll-view": "^2.0.1", "@gorhom/portal": "^1.0.14", "@invertase/react-native-apple-authentication": "^2.2.2", "@react-native-clipboard/clipboard": "^1.10.0", "@react-native-community/async-storage": "~1.12.0", "@react-native-community/checkbox": "^0.5.12", "@react-native-community/netinfo": "^9.3.0", "@react-native-community/picker": "^1.8.1", "@react-native-firebase/analytics": "^14.11.0", "@react-native-firebase/app": "^14.11.0", "@react-native-firebase/crashlytics": "^14.11.0", "@react-native-firebase/dynamic-links": "^14.11.0", "@react-native-firebase/firestore": "^14.11.0", "@react-native-firebase/messaging": "^14.11.0", "@react-native-google-signin/google-signin": "^8.0.0", "@react-native-masked-view/masked-view": "^0.2.7", "@react-navigation/bottom-tabs": "^6.3.2", "@react-navigation/drawer": "^6.4.3", "@react-navigation/elements": "^1.3.4", "@react-navigation/material-top-tabs": "^6.2.2", "@react-navigation/native": "^6.0.11", "@react-navigation/stack": "^6.2.2", "appcenter": "4.4.4", "appcenter-analytics": "4.4.4", "appcenter-crashes": "4.4.4", "axios": "^0.27.2", "formik": "^2.2.9", "i18next": "^21.8.14", "lodash": "^4.17.21", "lottie-react-native": "^5.1.3", "mixpanel-react-native": "^1.5.0", "moment": "^2.29.4", "native-base": "^3.4.9", "query-string": "^7.1.1", "react": "18.2.0", "react-dom": "18.2.0", "react-i18next": "^11.18.1", "react-native": "0.69.2", "react-native-adjust": "^4.29.6", "react-native-autocomplete-input": "^5.1.0", "react-native-code-push": "^7.0.4", "react-native-codegen": "^0.70.3", "react-native-config": "^1.4.6", "react-native-device-info": "^10.0.2", "react-native-fast-image": "^8.5.11", "react-native-fbsdk-next": "^10.0.0", "react-native-fs": "^2.20.0", "react-native-geolocation-service": "^5.3.0", "react-native-gesture-handler": "^2.5.0", "react-native-google-places-autocomplete": "^2.4.1", "react-native-gradle-plugin": "^0.70.0", "react-native-hyperlink": "^0.0.19", "react-native-image-pan-zoom": "^2.1.12", "react-native-image-picker": "^4.8.4", "react-native-image-zoom-viewer": "^3.0.1", "react-native-in-app-message": "^1.0.33", "react-native-inappbrowser-reborn": "^3.6.3", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.6.2", "react-native-loading-spinner-overlay": "^2.0.0", "react-native-maps": "^1.0.3", "react-native-modalize": "^2.0.13", "react-native-option-menu": "^1.1.3", "react-native-pager-view": "^5.4.25", "react-native-permissions": "^3.6.0", "react-native-qrcode-svg": "^6.1.2", "react-native-ratings": "^8.1.0", "react-native-reanimated": "^3.0.0-rc.0", "react-native-redash": "^18.0.0", "react-native-responsive-fontsize": "^0.5.1", "react-native-restart": "0.0.24", "react-native-safe-area-context": "4.3.1", "react-native-screens": "~3.15.0", "react-native-share": "^7.6.6", "react-native-shared-element": "^0.8.4", "react-native-skeleton-placeholder": "^5.0.0", "react-native-snap-carousel": "^4.0.0-beta.6", "react-native-splash-screen": "^3.3.0", "react-native-status-bar-height": "^2.6.0", "react-native-svg": "^12.4.0", "react-native-swiper": "^1.6.0", "react-native-tab-view": "^3.1.1", "react-native-toast-message": "^2.1.5", "react-native-tracking-transparency": "^0.1.1", "react-native-vector-icons": "^9.2.0", "react-native-video": "^5.2.0", "react-native-view-shot": "^3.3.0", "react-navigation-shared-element": "^3.1.3", "react-redux": "^8.0.2", "recombee-js-api-client": "^4.0.0", "redux": "^4.2.0", "redux-thunk": "^2.4.1", "yup": "^0.32.11" }, "devDependencies": { "@babel/core": "~7.18.9", "@react-native-community/eslint-config": "^3.0.3", "babel-jest": "~28.1.3", "eslint": "^8.20.0", "eslint-config-airbnb": "^19.0.4", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.6.0", "eslint-plugin-react": "^7.30.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-native": "^4.0.0", "jest": "~28.1.3", "metro-react-native-babel-preset": "^0.71.3", "metro-react-native-babel-transformer": "^0.71.3", "patch-package": "^6.4.7", "prettier": "^2.7.1", "react-native-svg-transformer": "^1.0.0", "react-test-renderer": "~18.2.0", "reactotron-react-native": "^5.0.2", "reactotron-redux": "^3.1.3" }, "jest": { "preset": "react-native" }, "private": true, "name": "null" }

AppDelegate.mm

`#import "AppDelegate.h"

import <React/RCTBridge.h>

import <React/RCTBundleURLProvider.h>

import <React/RCTRootView.h>

import <React/RCTAppSetupUtils.h>

import <React/RCTLinkingManager.h>

import "ReactNativeConfig.h"

import

import <GoogleMaps/GoogleMaps.h>

import <RNGoogleSignin/RNGoogleSignin.h>

//#import //#import //#import

import <CodePush/CodePush.h>

import <FBSDKCoreKit/FBSDKCoreKit.h>

if RCT_NEW_ARCH_ENABLED

import <React/CoreModulesPlugins.h>

import <React/RCTCxxBridgeDelegate.h>

import <React/RCTFabricSurfaceHostingProxyRootView.h>

import <React/RCTSurfacePresenter.h>

import <React/RCTSurfacePresenterBridgeAdapter.h>

import <ReactCommon/RCTTurboModuleManager.h>

import <react/config/ReactNativeConfig.h>

static NSString *const kRNConcurrentRoot = @"concurrentRoot";

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> { RCTTurboModuleManager _turboModuleManager; RCTSurfacePresenterBridgeAdapter _bridgeAdapter; std::shared_ptr _reactNativeConfig; facebook::react::ContextContainer::Shared _contextContainer; } @end

endif

@implementation AppDelegate

if RCT_NEW_ARCH_ENABLED

_contextContainer = std::make_shared(); _reactNativeConfig = std::make_shared(); _contextContainer->insert("ReactNativeConfig", _reactNativeConfig); _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer]; bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;

endif

NSDictionary initProps = [self prepareInitialProps]; UIView rootView = RCTAppSetupDefaultRootView(bridge, @"main", initProps);

if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; } else { rootView.backgroundColor = [UIColor whiteColor]; }

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; }

/// This method controls whether the concurrentRootfeature of React18 is turned on or off. /// /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). /// @return: true if the concurrentRoot feture is enabled. Otherwise, it returns false.

// Linking API

// Universal Links

if RCT_NEW_ARCH_ENABLED

pragma mark - RCTCxxBridgeDelegate

pragma mark RCTTurboModuleManagerDelegate

endif

@end `

Version

0.69

Output of npx react-native info

System: OS: macOS 12.3.1 CPU: (10) arm64 Apple M1 Pro Memory: 116.78 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.0.0 - /opt/homebrew/bin/node Yarn: 1.22.18 - /opt/homebrew/bin/yarn npm: 8.13.2 - /opt/homebrew/bin/npm Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /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: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 13.4.1/13F100 - /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.69.2 => 0.69.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

USE_FABRIC=1 RCT_NEW_ARCH_ENABLED=1 pod install

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

Screen Shot 2022-07-21 at 8 33 46 PM
github-actions[bot] commented 2 years ago
:warning: Missing Reproducible Example
:information_source: It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.
kelset commented 2 years ago

 @ahmadzraiq one thing I just noticed is that you have both react-native-codegen and react-native-gradle-plugin set to 0.70; that is probably related to the issue you are facing. You should not upgrade those until you migrate to RN 0.70.

ahmadzraiq commented 2 years ago

@kelset Same error

cortinico commented 2 years ago

one thing I just noticed is that you have both react-native-codegen and react-native-gradle-plugin set to 0.70; that is probably related to the issue you are facing. You should not upgrade those until you migrate to RN 0.70.

That's most likely the case. @mikehardy is this something that we want react-native doctor to inspect also (i.e. a set of dependencies should be aligned on the same minor)?

mikehardy commented 2 years ago

one thing I just noticed is that you have both react-native-codegen and react-native-gradle-plugin set to 0.70; that is probably related to the issue you are facing. You should not upgrade those until you migrate to RN 0.70.

That's most likely the case. @mikehardy is this something that we want react-native doctor to inspect also (i.e. a set of dependencies should be aligned on the same minor)?

In general doctor should check anything that is quantifiable and has known dependency ranges, this sounds like a good idea

ahmadzraiq commented 2 years ago

Any update?

kelset commented 2 years ago

@ahmadzraiq if I follow your repro steps, things work on my end. So either you can provide a more detailed repro that creates the same outcome on other machines (like mine) or it's probably just some configuration issues that is specific to your project - in which case, I'll close this issue.