构建 iOS 反应本机应用程序文件时出现致命错误,找不到“react/renderer/graphics/Float.h”

问题描述 投票:0回答:1

我使用XCode 13.4.1和react-native 0.73.3。从 XCode 构建我的反应本机项目,我在 RNReanimated 包中收到下一个错误:

Lexical or Preprocessor Issue:'react/renderer/graphics/Float.h' file not found.  
Pods > Development Pods > React-Fabric > core > ComponentDescriptor.h  

如果我注释掉这一行,则会在未找到其他“.h”文件中收到错误消息。似乎缺少一些路径,但我不知道是哪些路径。

这是我的 Podfile,我必须在其中添加一些更改:



    require_relative '../node_modules/react-native/scripts/react_native_pods'
    require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
    
    # Resolve react_native_pods.rb with node to allow for hoisting
    require Pod::Executable.execute_command('node', ['-p',
      'require.resolve(
        "react-native/scripts/react_native_pods.rb",
        {paths: [process.argv[1]]},
      )', __dir__]).strip
    
    platform :ios, '13.4'
    prepare_react_native_project!
    install! 'cocoapods', :deterministic_uuids => false
    
    linkage = ENV['USE_FRAMEWORKS']
    if linkage != nil
      Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
      use_frameworks! :linkage => linkage.to_sym
    end
    
    target 'MyApplication' do
      config = use_native_modules!
    
      # Flags change depending on the env values.
      flags = get_default_flags()
    
      use_react_native!(
        :path => config[:reactNativePath],
        # Hermes is now enabled by default. Disable by setting this flag to false.
        # Upcoming versions of React Native may rely on get_default_flags(), but
        # we make it explicit here to aid in the React Native upgrade process.
        :hermes_enabled => true,
        :fabric_enabled => flags[:fabric_enabled],
        # Enables Flipper.
        #
        # Note that if you have use_frameworks! enabled, Flipper will not work and
        # you should disable the next line.
        :flipper_configuration => FlipperConfiguration.enabled,
        # An absolute path to your application root.
        :app_path => "#{Pod::Config.instance.installation_root}/.."
      )
    
      pod 'RNFS', :path => '../node_modules/react-native-fs'
      pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
    
      pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
    
      pod 'Firebase', :modular_headers => true
      pod 'FirebaseCoreInternal', :modular_headers => true
      pod 'GoogleUtilities', :modular_headers => true
      pod 'FirebaseCore', :modular_headers => true
    
      target 'MyApplicationTests' do
        inherit! :complete
        # Pods for testing
      end
    
      post_install do |installer|
        # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
        react_native_post_install(
          installer,
          config[:reactNativePath],
          :mac_catalyst_enabled => false,
          # :ccache_enabled => true
        )
       
      end
    
    end

这是我的 package.json 文件,来自 React-native 项目:



    {
      "name": "myapplication",
      "version": "1.6.3",
      "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",
        "postinstall": "patch-package"
      },
      "dependencies": {
        "@react-native-community/cli": "^13.6.6",
        "@react-native-community/datetimepicker": "^3.5.2",
        "@react-native-community/masked-view": "^0.1.11",
        "@react-native-community/netinfo": "^6.1.0",
        "@react-native-community/progress-bar-android": "^1.0.4",
        "@react-native-community/progress-view": "^1.3.1",
        "@react-native-firebase/app": "^18.8.0",
        "@react-native-firebase/messaging": "^18.8.0",
        "@react-native-picker/picker": "^1.16.5",
        "@react-native/metro-config": "^0.74.81",
        "@react-navigation/bottom-tabs": "^6.0.1",
        "@react-navigation/native": "^6.0.1",
        "@react-navigation/stack": "^6.0.1",
        "@types/react": "^17",
        "axios": "^1.6.7",
        "deprecated-react-native-prop-types": "^2.3.0",
        "patch-package": "^6.4.7",
        "postinstall-postinstall": "^2.1.0",
        "react": "18.2.0",
        "react-native": "0.73.3",
        "react-native-autocomplete-dropdown": "1.1.6",
        "react-native-barcode-mask": "^1.2.4",
        "react-native-blob-util": "^0.16.2",
        "react-native-bottomsheet": "^2.5.2",
        "react-native-bouncy-checkbox": "^2.1.3",
        "react-native-camera": "^4.2.1",
        "react-native-eject": "^0.1.2",
        "react-native-file-viewer": "^2.1.4",
        "react-native-fs": "^2.18.0",
        "react-native-gesture-handler": "^1.10.3",
        "react-native-gradle-plugin": "^0.71.19",
        "react-native-image-pan-zoom": "^2.1.12",
        "react-native-mmkv": "^2.12.2",
        "react-native-paper": "^4.9.2",
        "react-native-pdf": "^6.6.0",
        "react-native-picker-select": "^8.0.4",
        "react-native-raw-bottom-sheet": "^2.2.0",
        "react-native-reanimated": "^2.2.0",
        "react-native-render-html": "^6.0.5",
        "react-native-safe-area-context": "^3.3.0",
        "react-native-screens": "^3.5.0",
        "react-native-splash-screen": "^3.2.0",
        "react-native-swipe-list-view": "^3.2.9",
        "react-native-swiper": "^1.6.0",
        "react-native-toast-message": "^1.4.9",
        "react-native-vector-icons": "9.2.0",
        "react-native-webview": "^11.6.6",
        "react-native-zip-archive": "^6.0.3",
        "rn-fetch-blob": "^0.12.0",
        "yarn": "^1.22.19"
      },
      "devDependencies": {
        "@babel/core": "^7.15.0",
        "@babel/runtime": "^7.14.8",
        "@react-native-community/eslint-config": "^3.0.0",
        "@types/jest": "^26.0.24",
        "@types/react-native": "^0.64.12",
        "@types/react-native-vector-icons": "^6.4.8",
        "@types/react-test-renderer": "^17.0.1",
        "babel-jest": "^27.0.6",
        "eslint": "^7.32.0",
        "jest": "^27.0.6",
        "metro-config": "^0.80.5",
        "metro-react-native-babel-preset": "^0.72.1",
        "react-test-renderer": "^18.2.0",
        "typescript": "^4.3.5",
        "yarn-upgrade-all": "^0.5.4"
      },
      "resolutions": {
        "@types/react": "^17"
      },
      "jest": {
        "preset": "react-native",
        "moduleFileExtensions": [
          "ts",
          "tsx",
          "js",
          "jsx",
          "json",
          "node"
        ]
      },
      "description": "My custom App",
      "main": "index.js",
      "repository": "",
      "author": "author",
      "license": "Private"
    }

我必须修补 RNReanimated.podspec 才能设置 C++ 编译器版本:

s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" ",
"FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17", <--- I've added this line

}

如果我需要添加任何其他文件来解决此问题,请询问我。

ios react-native react-native-reanimated react-native-reanimated-v2
1个回答
0
投票

经过一番尝试和失败,我最终将 XCode 更新到 14.2,并将 RN Reanimated 更新到版本 ^3(在包中被锁定为版本 2)。然后,在此之后,我可以编译该项目,没有任何错误。

© www.soinside.com 2019 - 2024. All rights reserved.