首页 > 解决方案 > 升级 react-native (0.60) 后,我遇到了 React/{Any filename}.h' file not found error with different packages

问题描述

无法构建应用程序我收到导入文件的错误未找到不同包的错误

所以我尝试使用 import 来导入“{Any filename}.h”

但是我反复遇到 react-native-linear-gradient、fast-image、webview 等错误

❌ node_modules/react-native-fast-image/ios/FastImage/FFFastImageViewManager.h:1:9: 'React/RCTViewManager.h' 文件未找到

❌ node_modules/react-native-fast-image/ios/FastImage/RCTConvert+FFFastImage.h:1:9: 'React/RCTConvert.h' 文件未找到

进口

^~~~~~~~~~~~~~~~~~~~

进口

React/RCTViewManager.h' 文件未找到(这是由于线性渐变)包)

标签: react-nativelinear-gradients

解决方案


我个人在此处添加了一些代码来Podefile解决标题搜索路径问题

  post_install do |installer|
    puts 'post_install'
    app_project = Xcodeproj::Project.open("./X.xcodeproj")
    output = `find .. -name "*.xcodeproj"`
    p output
    output.split("\n").each do |projectPath|
      app_project = Xcodeproj::Project.open(projectPath)
      app_project.native_targets.each do |target|
        target.build_configurations.each do |config|
          if !config.build_settings['HEADER_SEARCH_PATHS']
            config.build_settings['HEADER_SEARCH_PATHS'] ||= []
          end
          config.build_settings['HEADER_SEARCH_PATHS'] << ' $(SRCROOT)/Pods/Headers/**'
          config.build_settings['HEADER_SEARCH_PATHS'] <<' $(SRCROOT)/../../../../ios/Pods/Headers/**'
          config.build_settings['HEADER_SEARCH_PATHS'] << ' $(SRCROOT)/../../../ios/Pods/Headers/**'
          config.build_settings['HEADER_SEARCH_PATHS'] << ' $(SRCROOT)/../../ios/Pods/Headers/**'
          config.build_settings['HEADER_SEARCH_PATHS'] << ' $(SRCROOT)/../ios/Pods/Headers/**'
          app_project.save
        end
      end  
    end
    puts 'post_install DONE'
  end

我希望我能帮上忙


推荐阅读