react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Could not build module 'React' from REAEventDispatcher.h #import <React/RCTEventDispatcher.h>

Open numandev1 opened this issue 3 years ago • 6 comments

Description

I was just enabling NEW_ARCH by USE_FABRIC=1 RCT_NEW_ARCH_ENABLED=1 pod install and getting these errors from Xcode

/project/ios/Pods/Headers/Public/hermes-engine/hermes/hermes.h:11:10: 'exception' file not found

/project/ios/Pods/Headers/Private/React-bridging/react/bridging/react/bridging/LongLivedObject.h:10:10: 'memory' file not found

/project/node_modules/react-native-reanimated/ios/REAEventDispatcher.h:2:9: Could not build module 'React'

image

Noted: when i click on jump to Defination for #import <React/RCTEventDispatcher.h> it is jumping correctly.

Steps to reproduce

  • Create Project with expo bare
  • add the same versions
  • goto ios directory and run this command USE_FABRIC=1 RCT_NEW_ARCH_ENABLED=1 pod install
  • try to build an app from Xcode. these errors will occur

you can try these versions

{
  "name": "project",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
    "pre-commit": "lint-staged --verbose",
    "prepare": "husky install",
    "postinstall": "patch-package"
  },
  "lint-staged": {
    "*.(js|jsx|ts|tsx)": [
      "pretty-quick --staged",
      "eslint \"**/*.{js,ts,tsx}\""
    ]
  },
  "dependencies": {
    "@apollo/client": "3.6.9",
    "@expo/react-native-action-sheet": "^3.13.0",
    "@gorhom/bottom-sheet": "^4.4.3",
    "@invertase/react-native-apple-authentication": "2.2.2",
    "@react-native-async-storage/async-storage": "1.17.7",
    "@react-native-clipboard/clipboard": "^1.10.0",
    "@react-native-community/geolocation": "2.1.0",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-firebase/analytics": "^15.2.0",
    "@react-native-firebase/app": "^15.2.0",
    "@react-native-firebase/app-check": "^15.2.0",
    "@react-native-firebase/auth": "^15.2.0",
    "@react-native-firebase/messaging": "^15.2.0",
    "@react-native-google-signin/google-signin": "^8.0.0",
    "@react-native-picker/picker": "2.4.2",
    "@react-navigation/bottom-tabs": "6.3.2",
    "@react-navigation/native": "6.0.11",
    "@react-navigation/native-stack": "6.7.0",
    "@rudderstack/rudder-integration-clevertap-react-native": "1.0.2",
    "@rudderstack/rudder-sdk-react-native": "1.4.1",
    "@shopify/flash-list": "^1.2.0",
    "add": "^2.0.6",
    "aia-react-native-idfa": "^5.0.1",
    "axios": "0.27.2",
    "clevertap-react-native": "^0.8.1",
    "deprecated-react-native-prop-types": "^2.3.0",
    "expo": "46.0.3",
    "expo-haptics": "11.3.0",
    "expo-jwt": "^1.4.1",
    "expo-localization": "13.1.0",
    "expo-secure-store": "11.3.0",
    "expo-web-browser": "11.0.0",
    "formik": "^2.2.9",
    "frames-react-native": "1.1.8",
    "graphql": "16.5.0",
    "i18n-js": "3.9.2",
    "immer": "9.0.15",
    "intl": "^1.2.5",
    "lottie-ios": "3.2.3",
    "lottie-react-native": "5.1.3",
    "moment": "2.29.4",
    "patch-package": "^6.4.7",
    "popmotion": "^11.0.3",
    "postinstall-postinstall": "^2.1.0",
    "qs": "6.11.0",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-native": "0.69.4",
    "react-native-actionsheet": "^2.4.2",
    "react-native-adjust": "4.31.0",
    "react-native-animatable": "^1.3.3",
    "react-native-apay": "1.3.1",
    "react-native-appstate-hook": "^1.0.6",
    "react-native-blurhash": "1.1.10",
    "react-native-code-push": "^7.0.5",
    "react-native-codegen": "^0.71.0",
    "react-native-compressor": "^1.5.2",
    "react-native-confirmation-code-field": "^7.3.0",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-device-info": "^10.0.2",
    "react-native-elements": "^3.4.2",
    "react-native-event-listeners": "^1.0.7",
    "react-native-fast-image": "^8.5.11",
    "react-native-flash-message": "^0.2.1",
    "react-native-fs": "^2.20.0",
    "react-native-gesture-handler": "2.5.0",
    "react-native-google-places-autocomplete": "^2.4.1",
    "react-native-gradle-plugin": "^0.71.0",
    "react-native-image-picker": "^4.8.4",
    "react-native-in-app-review": "^4.1.1",
    "react-native-keyboard-accessory": "^0.1.16",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-keyboardawareview-spacer": "^0.0.2",
    "react-native-linear-gradient": "2.6.2",
    "react-native-lottie-splash-screen": "^1.0.1",
    "react-native-maps": "^1.1.0",
    "react-native-mmkv": "2.4.3",
    "react-native-modal": "^13.0.1",
    "react-native-normalize": "^1.0.1",
    "react-native-notifications": "4.3.1",
    "react-native-pager-view": "5.4.25",
    "react-native-portalize": "^1.0.7",
    "react-native-progress": "^5.0.0",
    "react-native-ratings": "^8.1.0",
    "react-native-reanimated": "3.0.0-rc.0",
    "react-native-reanimated-carousel": "3.0.3",
    "react-native-remix-icon": "^0.3.0",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-restart": "^0.0.24",
    "react-native-root-siblings": "^4.1.1",
    "react-native-safe-area-context": "4.3.1",
    "react-native-screens": "3.15.0",
    "react-native-shadow-2": "^6.0.6",
    "react-native-shimmer": "^0.6.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-stomp-websocket": "^1.0.8",
    "react-native-svg": "^12.4.3",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-tracking-transparency": "^0.1.1",
    "react-native-webview": "11.22.7",
    "react-redux": "8.0.2",
    "read-json-lines-sync": "2.2.2",
    "recoil": "0.7.4",
    "recyclerlistview": "4.1.1",
    "redux": "4.2.0",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.1.3",
    "reselect": "4.1.6",
    "rn-card-scanner": "^1.1.0",
    "rn-user-defaults": "^1.8.2",
    "tiny-emitter": "^2.1.0",
    "typesense": "1.3.0",
    "urijs": "1.19.11",
    "yarn": "^1.22.19",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.18.9",
    "@react-native-community/eslint-config": "^3.1.0",
    "@types/i18n-js": "^3.8.2",
    "@types/jest": "^26.0.23",
    "@types/qs": "^6.9.7",
    "@types/react-native": "^0.69.5",
    "@types/react-native-snap-carousel": "^3.8.5",
    "@types/react-test-renderer": "^17.0.1",
    "@typescript-eslint/eslint-plugin": "^5.7.0",
    "@typescript-eslint/parser": "^5.32.0",
    "appcenter-cli": "2.11.0",
    "babel-jest": "^28.1.3",
    "babel-preset-expo": "^9.2.0",
    "eslint": "^8.21.0",
    "eslint-config-universe": "^10.0.0",
    "husky": "^7.0.4",
    "jest": "^26.6.3",
    "lint-staged": "^13.0.3",
    "metro-react-native-babel-preset": "^0.72.0",
    "prettier": "^2.5.1",
    "pretty-quick": "^3.1.3",
    "react-native-dotenv": "^3.3.1",
    "react-native-svg-transformer": "^1.0.0",
    "react-test-renderer": "18.0.0",
    "typescript": "^4.7.4",
    "yarn-upgrade-all": "^0.6.1"
  },
  "resolutions": {
    "@types/react": "^17",
    "react-native-redash": "18.0.0"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  }
}

Snack or a link to a repository

will add later

Reanimated version

3.0.0-rc.0

React Native version

0.69.4

Platforms

iOS

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

iPhone 13 pro max

Acknowledgements

Yes

numandev1 avatar Aug 12 '22 06:08 numandev1

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Platforms section.

github-actions[bot] avatar Aug 12 '22 06:08 github-actions[bot]

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar Aug 12 '22 06:08 github-actions[bot]

Hey @nomi9995, thanks for reporting the issue.

/project/ios/Pods/Headers/Public/hermes-engine/hermes/hermes.h:11:10: 'exception' file not found /project/ios/Pods/Headers/Private/React-bridging/react/bridging/react/bridging/LongLivedObject.h:10:10: 'memory' file not found

These errors look quite serious and suggest that C++ standard library cannot be found when compiling React sources.

Can you check in Xcode if these files (hermes.h and LongLivedObject.h) are recognized as C++ sources?

I would also recommend performing the following steps:

  • Clean Build Folder in Xcode
  • Reinstall Pods with cd ios && rm -rf Podfile.lock Pods

Please let us know if it helps.

edit: Also, most of the dependencies in package.json don't support Fabric yet.

tomekzaw avatar Aug 12 '22 07:08 tomekzaw

@tomekzaw I have tried removing Podfile.lock Pods derivedData directory but I am getting the same error

image

how can I check hermes.h is a C++ source or not?

numandev1 avatar Aug 12 '22 11:08 numandev1

how can I check hermes.h is a C++ source or not?

When you open the file in Xcode, on the right side there is "Type" selectbox:

Zrzut ekranu 2022-08-12 o 13 36 52

But I cannot find hermes.h in Xcode. Moreover, even if I open JSCRuntime.h (which is definitely a C++ header) it says "Default - C Header" 😢 So this is not the right way.

Can you temporarily remove all dependencies from your app that do not support Fabric yet? I think this might be the problem.

tomekzaw avatar Aug 12 '22 11:08 tomekzaw

@tomekzaw It is also showing me "Default - C Header" all three file hermes.h, LongLivedObject.h and REAEventDispatcher.h

here you can find hermes.h ios/Pods/hermes-engine/destroot/include/hermes/hermes.h image

My Xcode is lazy. this bug made me soo much tired. I will come back to this bug another day. thanks a lot for your help

numandev1 avatar Aug 12 '22 12:08 numandev1

the same issue with my project:

image

MichDreby avatar Aug 15 '22 12:08 MichDreby

Hey @MichDreby, can you share some more details like RN version, Reanimated version etc.?

tomekzaw avatar Aug 16 '22 06:08 tomekzaw

Hi @tomekzaw, thanks for replying.


Package.json:

"dependencies": {
    "@apollo/client": "^3.4.16",
    "@expo/react-native-action-sheet": "3.13.0",
    "@microsoft/applicationinsights-react-native": "^2.2.9",
    "@microsoft/applicationinsights-web": "^2.5.11",
    "@notifee/react-native": "^3.0.4",
    "@react-native-async-storage/async-storage": "1.17.9",
    "@react-native-community/blur": "^3.6.0",
    "@react-native-community/cameraroll": "4.0.4",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-community/netinfo": "^6.0.2",
    "@react-native-community/progress-bar-android": "^1.0.4",
    "@react-native-community/progress-view": "^1.2.4",
    "@react-native-community/push-notification-ios": "^1.10.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/messaging": "14.11.0",
    "@react-native-picker/picker": "^1.16.8",
    "@react-navigation/bottom-tabs": "6.3.2",
    "@react-navigation/elements": "1.3.4",
    "@react-navigation/material-top-tabs": "6.2.2",
    "@react-navigation/native": "6.0.11",
    "@react-navigation/native-stack": "6.7.0",
    "@react-navigation/stack": "6.2.2",
    "@testing-library/react-hooks": "^3.4.2",
    "@types/omit-deep-lodash": "^1.1.0",
    "@types/react-native-snap-carousel": "^3.8.4",
    "@types/string.prototype.matchall": "^4.0.0",
    "@types/yup": "^0.29.8",
    "apollo-link-http": "^1.5.17",
    "apollo-link-queue": "^3.1.0",
    "camelcase-keys": "^6.2.2",
    "card-validator": "^8.1.0",
    "core-js": "^3.12.1",
    "date-fns": "2.23.0",
    "date-fns-tz": "^1.1.6",
    "deprecated-react-native-prop-types": "^2.3.0",
    "expo": "46.0.7",
    "expo-camera": "12.2.0",
    "expo-location": "14.2.2",
    "expo-media-library": "14.1.0",
    "expo-permissions": "13.2.0",
    "formik": "^2.2.1",
    "graphql": "^15.3.0",
    "graphql-tag": "^2.12.4",
    "i18next": "^19.7.0",
    "js-base64": "^3.7.2",
    "jwt-decode": "^3.1.2",
    "lodash": "^4.17.20",
    "loglevel": "^1.7.1",
    "metro-config": "^0.66.1",
    "omit-deep-lodash": "^1.1.5",
    "patch-package": "^6.4.7",
    "react": "18.0.0",
    "react-i18next": "^11.7.3",
    "react-native": "0.69.4",
    "react-native-video": "^5.2.0",
    "react-native-android-downloading-notifications": "0.0.3",
    "react-native-android-keyboard-adjust": "^1.2.0",
    "react-native-app-auth": "^6.0.1",
    "react-native-base64": "^0.2.1",
    "react-native-calendars": "1.1284.0",
    "react-native-check-app-install": "redpandatronicsuk/react-native-check-app-install",
    "react-native-codegen": "0.71.0",
    "react-native-date-picker": "^4.2.0",
    "react-native-device-info": "^7.0.2",
    "react-native-document-picker": "^5.0.3",
    "react-native-exception-handler": "^2.10.10",
    "react-native-fast-image": "^8.5.11",
    "react-native-file-viewer": "^2.1.4",
    "react-native-fingerprint-scanner": "^6.0.0",
    "react-native-fs": "^2.17.0",
    "react-native-gesture-handler": "2.5.0",
    "react-native-gradle-plugin": "0.70.1",
    "react-native-image-picker": "4.8.4",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-json-tree": "^1.3.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.3",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-localize": "^2.1.4",
    "react-native-map-clustering": "^3.4.2",
"react-native-maps": "^1.0.0",
"react-native-orientation-locker": "^1.5.0",
    "react-native-map-link": "^2.8.2",
    "react-native-masked-text": "^1.13.0",
    "react-native-modal": "^13.0.0",
    "react-native-pager-view": "^5.4.6",
    "react-native-parsed-text": "0.0.22",
    "react-native-pdf": "^6.2.2",
    "react-native-rate": "^1.2.9",
    "react-native-reanimated": "3.0.0-rc.0",
    "react-native-render-html": "^5.1.0",
    "react-native-safe-area-context": "^3.1.8",
    "react-native-screens": "3.15.0",
    "react-native-shake": "^5.0.1",
    "react-native-size-matters": "^0.4.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-splash-screen": "^3.2.0",
    "react-native-status-bar-height": "^2.5.0",
    "react-native-svg": "12.1.0",
    "react-native-tab-view": "3.1.1",
    "react-native-toast-notifications": "^3.2.2",
    "react-native-ultimate-config": "4.0.0",
    "react-native-uuid": "^2.0.0",
    "react-native-webview": "11.22.7",
    "requestidlecallback-polyfill": "^1.0.2",
    "rn-fetch-blob": "^0.12.0",
    "rn-secure-storage": "^2.0.6",
    "sendbird": "3.1.17",
    "stack-beautifier": "^1.0.2",
    "string.prototype.matchall": "^4.0.3",
    "uuid-by-string": "^3.0.7",
    "victory-core": "^36.2.0",
    "victory-native": "^36.2.0",
    "yup": "^0.29.3"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/preset-env": "^7.12.1",
    "@babel/preset-typescript": "^7.12.1",
    "@babel/runtime": "^7.12.5",
    "@commitlint/cli": "^11.0.0",
    "@commitlint/config-conventional": "^11.0.0",
    "@graphql-codegen/cli": "^1.19.1",
    "@graphql-codegen/typescript": "^1.17.11",
    "@react-native-community/eslint-config": "^1.1.0",
    "@storybook/addon-actions": "^6.3.8",
    "@storybook/addon-knobs": "^5.3.21",
    "@storybook/addon-links": "^6.3.8",
    "@storybook/addon-ondevice-actions": "^5.3.23",
    "@storybook/addon-ondevice-knobs": "^5.3.25",
    "@storybook/addons": "^6.3.8",
    "@storybook/react-native": "^5.3.25",
    "@storybook/react-native-server": "^5.3.23",
    "@testing-library/react-hooks": "^3.7.0",
    "@testing-library/react-native": "^7.0.2",
    "@types/i18next": "^13.0.0",
    "@types/jest": "^26.0.24",
    "@types/lodash": "^4.14.165",
    "@types/loglevel": "^1.6.3",
    "@types/react-gateway": "^2.8.3",
    "@types/react-i18next": "^8.1.0",
    "@types/react-native": "^0.69.3",
    "@types/react-native-dotenv": "^0.2.0",
    "@types/react-test-renderer": "^16.9.2",
    "@typescript-eslint/eslint-plugin": "^4.1.1",
    "@typescript-eslint/parser": "^4.1.1",
    "babel-jest": "^26.6.3",
    "babel-loader": "^8.1.0",
    "babel-plugin-module-resolver": "^4.0.0",
    "babel-plugin-resolve-barrel-files": "0.2.0",
    "eslint": "^7.14.0",
    "eslint-config-airbnb": "^18.2.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-barrel-files": "./libs/eslint-plugin-barrel-files",
    "eslint-plugin-import": "2.25.4",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-path": "1.0.1",
    "eslint-plugin-react": "^7.21.2",
    "eslint-plugin-react-hooks": "^4.0.0",
    "eslint-plugin-react-native": "^4.0.0",
    "eslint-plugin-simple-import-sort": "^7.0.0",
    "eslint-plugin-sonarjs": "^0.11.0",
    "eslint-plugin-unused-imports": "^2.0.0",
    "husky": "^4.3.0",
    "i18next-scanner": "^2.11.0",
    "i18next-scanner-typescript": "^1.0.6",
    "jest": "^26.6.3",
    "jest-junit": "^12.0.0",
    "lint-staged": "^10.4.0",
    "metro-react-native-babel-preset": "0.66.2",
    "mock-apollo-client": "^1.2.0",
    "mockdate": "^3.0.2",
    "react-dom": "18.0.0",
    "react-native-dotenv": "^2.5.0",
    "react-native-svg-transformer": "^0.14.3",
    "react-test-renderer": "17.0.2",
    "typescript": "^4.1.0"
  }

Podfile:

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false


target 'AppName' do
  use_expo_modules!
  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end

  config = use_native_modules!

  # 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 => true,
    :fabric_enabled => flags[:fabric_enabled],
    :flipper_configuration => FlipperConfiguration.enabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'AppNameTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
      end
    end
  end
end

AppDelegate.mm:

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import <React/RCTLinkingManager.h>
#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>
#import <RNFBMessagingModule.h>


#import <React/RCTAppSetupUtils.h>
#import "Orientation.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";
#endif


#if RCT_NEW_ARCH_ENABLED
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate, UNUserNotificationCenterDelegate, FIRMessagingDelegate> {
  RCTTurboModuleManager *_turboModuleManager;
  RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
  std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
  facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#else
@interface AppDelegate () <UNUserNotificationCenterDelegate, FIRMessagingDelegate> {}
@end
#endif


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [FIRApp configure];

  RCTAppSetupPrepareApp(application);

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

  NSDictionary *initProps = [RNFBMessagingModule addCustomPropsToUserProps:nil withLaunchOptions:launchOptions];
  UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"AppName", initProps);

  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;

  [FIRMessaging messaging].delegate = self;

  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  [application registerForRemoteNotifications];


#if RCT_NEW_ARCH_ENABLED
  _contextContainer = std::make_shared<facebook::react::ContextContainer const>();
  _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
  _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
  _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
  bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif



  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];

  [RNSplashScreen show];

  [super application:application didFinishLaunchingWithOptions:launchOptions];

  return YES;
}

/// This method controls whether the `concurrentRoot`feature 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`.
- (BOOL)concurrentRootEnabled
{
  // Switch this bool to turn on and off the concurrent root
  return true;
}

- (NSDictionary *)prepareInitialProps
{
  NSMutableDictionary *initProps = [NSMutableDictionary new];

#ifdef RCT_NEW_ARCH_ENABLED
  initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
#endif

  return initProps;
}

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
  return [Orientation getOrientation];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *) options {
  if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url])
  {
    return YES;
  }
  return [RCTLinkingManager application:app openURL:url options:options];
}

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNCPushNotificationIOS didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [FIRMessaging messaging].APNSToken = deviceToken;
  [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler
{
  [[FIRMessaging messaging] appDidReceiveMessage:userInfo];
  completionHandler(UIBackgroundFetchResultNoData);
  [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
 [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)(void))completionHandler
{
  [RNCPushNotificationIOS didReceiveNotificationResponse:response];
  NSDictionary *userInfo = response.notification.request.content.userInfo;
  [[FIRMessaging messaging] appDidReceiveMessage:userInfo];
  completionHandler();
}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
  NSDictionary *userInfo = notification.request.content.userInfo;
  [[FIRMessaging messaging] appDidReceiveMessage:userInfo];
  [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo
                                  fetchCompletionHandler:^void (UIBackgroundFetchResult result){}];
  completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
}

#if RCT_NEW_ARCH_ENABLED

#pragma mark - RCTCxxBridgeDelegate

- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
  _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
                                                             delegate:self
                                                            jsInvoker:bridge.jsCallInvoker];
  return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}

#pragma mark RCTTurboModuleManagerDelegate

- (Class)getModuleClassFromName:(const char *)name
{
  return RCTCoreModulesClassProvider(name);
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                      jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
  return nullptr;
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                     initParams:
                                                         (const facebook::react::ObjCTurboModule::InitParams &)params
{
  return nullptr;
}

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
  return RCTAppSetupDefaultModuleFromClass(moduleClass);
}

#endif

@end

MichDreby avatar Aug 17 '22 09:08 MichDreby

@tomekzaw here is the repro, i will also try to fix it from repro https://github.com/nomi9995/fabric-reanimated-repro

numandev1 avatar Aug 22 '22 14:08 numandev1

@tomekzaw I confirm that this error is due to an expo "expo": "46.0.8", if I remove this then the project is working good otherwise above error is happening. you can also test repro

numandev1 avatar Aug 23 '22 07:08 numandev1

@nomi9995 Thanks a lot for the investigation! Also, does Expo already support Fabric?

tomekzaw avatar Aug 23 '22 09:08 tomekzaw

@tomekzaw I also don't know if Expo 46 supports Fabric or not. let me confirm

numandev1 avatar Aug 23 '22 11:08 numandev1

@tomekzaw expo 46 does not support fabric. here is the reply from the expo team(@tsapeta).

No, just like many other libraries, there are just a few that support Fabric. However, I can already reveal the news that in SDK47 expo-linear-gradient, video from expo-av and expo-camera will have experimental support for Fabric 😉

numandev1 avatar Aug 23 '22 12:08 numandev1

Thanks for the update! Closing the issue as it's not a bug in Reanimated. Looking forward to Fabric support in Expo! 😄

tomekzaw avatar Aug 23 '22 13:08 tomekzaw