草庐IT

ios - codepush 和 cocoapods 找不到 React/RCTEventEmitter.h

coder 2024-01-13 原文

我很难诊断我的 iOS React native 构建失败的原因。在诊断了一些其他错误之后,我现在面临的问题是,无论我尝试什么,错误 React/RCTEventEmitter.h not found 困扰着我和我的应用程序。这只是一个由 react-native init 创建的基本 react-native 应用程序。

我几乎尝试了以下所有组合:

  • 更改“ header 搜索路径”
  • 删除创建的 xcode/DeriveData 文件夹
  • “解体” pod
  • pods 安装
  • 将 react-native-code-push xcodeproject/library 直接拖放到我在 Libraries 中的 xbox 中的应用
  • xcode 干净
  • react native 链接
  • react-native 链接代码推送
  • 从 Podfile 中删除 codepush
  • 正在删除 ios/Pods 文件夹
  • 正在删除 ios/Podfile.lock 文件
  • 使用 xcodebuild 手动构建应用(同样的错误)
/usr/bin/xcodebuild -sdk iphoneos -workspace ios/myApp.xcworkspace -scheme myApp  archive -archivePath myApp.xcarchive -UseModernBuildSystem=NO CODE_SIGNING_ALLOWED=NO

我的 react 信息如下(它是一个 macOS VM):

    System:
      OS: macOS High Sierra 10.13.1
      CPU: (4) x64 AMD Ryzen 7 1700X Eight-Core Processor         
      Memory: 102.70 MB / 4.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.11.0 - ~/.nvm/versions/node/v11.11.0/bin/node
      Yarn: 1.13.0 - ~/.nvm/versions/node/v11.11.0/bin/yarn
      npm: 6.7.0 - ~/.nvm/versions/node/v11.11.0/bin/npm
    SDKs:
      iOS SDK:
        Platforms: iOS 11.2, macOS 10.13, tvOS 11.2, watchOS 4.2
    IDEs:
      Xcode: 9.2/9C40b - /usr/bin/xcodebuild
    npmPackages:
      react: 16.4.1 => 16.4.1 
      react-native: 0.57.0-rc.0 => 0.57.0-rc.0 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native: 0.58.6

我的 Podfile 是:

target 'myApp' do
  # Pods for AppCenter
  pod 'AppCenter/Crashes', '~> 1.13.0'
  pod 'AppCenter/Analytics', '~> 1.13.0'
  pod 'AppCenterReactNativeShared', '~> 1.12.0'
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for myApp


  platform :ios, '9.0'
  pod 'CodePush', :path => '../node_modules/react-native-code-push'

end

我面临的确切错误是:

/Users/administrator/Desktop/BUILD/myApp/node_modules/react-native-code-push/ios/CodePush/CodePush.h:6:9: fatal error: 'React/RCTEventEmitter.h' file not found
#import "React/RCTEventEmitter.h"   // Required when used as a Pod in a Swift project

虽然我对 iOS 开发还很陌生,但我上面所做的似乎应该可以解决问题,但事实并非如此。这个错误看起来很明显,但我不知道还能做什么。

我知道有很多关于这个问题的文章,但我看到的大多数文章/问题都是可以解决的,但出于某种原因,我面临的具体案例似乎非同寻常。我想知道是否有人有任何其他提示或遇到过这样的问题?非常感谢任何帮助!

最佳答案

错误被触发at this line仅当用作 Swift 项目

中的 Pod 时才需要
#import "React/RCTEventEmitter.h"   // Required when used as a Pod in a Swift project

问题似乎是由这个 pull request 引起的,我建议你使用最新版本的react-native-code-push@5.6react-native 0.57 兼容。

尝试以下方法解决问题

1) 确保为 Swift 正确配置了 Podfile 如果您使用的是 swift,请将 use_frameworks! 添加到 podfile

# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
use_frameworks!

2) 重新安装并配置 react-native-code-push 到最新版本 5.6

npm uninstall react-native-code-push
npm install --save react-native-code-push@5.6.0

关注ios setupplugin configuration

4) 安装app center as by instructions

如果问题没有解决

5) Add the following linenode_modules/react-native-code-push/ios/CodePush/CodePush.h

#import "React/RCTEventEmitter.h"

#import "RCTEventEmitter.h"

#import <React/RCTEventEmitter.h>

如果上述解决方案不能解决问题

6) Remove the following line from ios/AppDelegate.m

#import "CodePush.h"

and add

#import <CodePush/CodePush.h>

问题是由以下几行node_modules/react-native-code-push/blob/master/ios/CodePush/CodePush.h引起的. 所有 if 语句都失败(意味着这些类不可用)并且 第 6 行 正在执行。

line 1 #if __has_include(<React/RCTEventEmitter.h>)
line 2 #import <React/RCTEventEmitter.h>
line 3 #elif __has_include("RCTEventEmitter.h")
line 4 #import "RCTEventEmitter.h"
line 5 #else
line 6 #import "React/RCTEventEmitter.h"   // Required when used as a Pod in a Swift project
line 7 #endif

我很乐意帮助您进一步解决这个问题

关于ios - codepush 和 cocoapods 找不到 React/RCTEventEmitter.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55151487/

有关ios - codepush 和 cocoapods 找不到 React/RCTEventEmitter.h的更多相关文章

  1. ruby - 如何验证 IO.copy_stream 是否成功 - 2

    这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下

  2. Ruby 文件 IO 定界符? - 2

    我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的

  3. Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting - 2

    1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里

  4. ruby-on-rails - rbenv:从 RVM 移动到 rbenv 后,在 Jenkins 执行 shell 中找不到命令 - 2

    我从Ubuntu服务器上的RVM转移到rbenv。当我使用RVM时,使用bundle没有问题。转移到rbenv后,我在Jenkins的执行shell中收到“找不到命令”错误。我内爆并删除了RVM,并从~/.bashrc'中删除了所有与RVM相关的行。使用后我仍然收到此错误:rvmimploderm~/.rvm-rfrm~/.rvmrcgeminstallbundlerecho'exportPATH="$HOME/.rbenv/bin:$PATH"'>>~/.bashrcecho'eval"$(rbenvinit-)"'>>~/.bashrc.~/.bashrcrbenvversions

  5. ruby-on-rails - 找不到 gem railties (>= 0.a) (Gem::GemNotFoundException) - 2

    我已经看到了一些其他的问题,尝试了他们的建议,但没有一个对我有用。我已经使用Rails大约一年了,刚刚开始一个新的Rails项目,突然遇到了问题。我卸载并尝试重新安装所有Ruby和Rails。Ruby很好,但Rails不行。当我输入railss时,我得到了can'tfindgemrailties。我当前的Ruby版本是ruby2.2.2p95(2015-04-13修订版50295)[x86_64-darwin15],尽管我一直在尝试通过rbenv设置ruby​​2.3.0。如果我尝试rails-v查看我正在运行的版本,我会得到同样的错误。我使用的是MacOSXElCapitan版本10

  6. 即使安装了 gem,Ruby 也找不到所需的库 - 2

    我花了几天时间尝试安装ruby​​1.9.2并让它与gems一起工作:-/我最终放弃了我的MacOSX10.6机器,下面是我的Ubuntu机器上的当前状态。任何建议将不胜感激!#rubytest.rb:29:in`require':nosuchfiletoload--mongo(LoadError)from:29:in`require'fromtest.rb:1:in`'#cattest.rbrequire'mongo'db=Mongo::Connection.new.db("mydb")#gemwhichmongo/usr/local/rvm/gems/ruby-1.9.2-p0/g

  7. ruby - 为什么不能使用类IO的实例方法noecho? - 2

    print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上

  8. ruby - Sinatra 找不到 View 目录 - 2

    我正在尝试以一种更类似于普通RubyGem结构的方式构建我的Sinatra应用程序。我有以下文件树:.├──app.rb├──config.ru├──Gemfile├──Gemfile.lock├──helpers│  ├──dbconfig.rb│  ├──functions.rb│  └──init.rb├──hidden│  └──Rakefile├──lib│  ├──admin.rb│  ├──api.rb│  ├──indexer.rb│  ├──init.rb│  └──magnet.rb├──models│  ├──init.rb│  ├──invite.rb│  ├─

  9. ruby - 在 SUSE 上找不到 Ruby 的头文件? - 2

    我正在尝试在SUSEEnterprise11SP3上安装compass。我得到以下信息。有什么想法吗?geminstallcompassBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingcompass:ERROR:Failedtobuildgemnativeextension./usr/bin/rubyextconf.rbmkmf.rbcan'tfindheaderfilesforrubyat/usr/lib64/ruby/ruby.hextconffailed,exitcode1Gemfileswi

  10. ruby-on-rails - Heroku 找不到 SecureRandom - 2

    我的heroku应用崩溃了,因为它找不到模块“SecureRandom”。我在gemfile中指定了我的Ruby版本,我的计算机、gemfile和Heroku似乎都匹配Ruby版本号,尽管不是补丁号。其他帖子建议将usr/bin/heroku指向特定的Ruby文件,但我不确定该怎么做(我的应用程序中没有Herokubin)。这看起来像是Ruby版本错误。我该如何解决这个问题?classOrderItemHeroku日志:/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependenci

随机推荐