使用codepush和cocoapods找不到React / RCTEventEmitter.h

问题描述 投票:3回答:4

我在诊断我的iOS反应原生构建失败的原因方面存在很大问题。在诊断出其他一些错误之后,我现在面临的问题是无论我尝试什么,都没有发现错误React / RCTEventEmitter.h困扰我和我的应用程序。这只是react-native init创建的基本反应本机应用程序。

我尝试了以下几种组合:

  • 更改“标题搜索路径”
  • 删除创建的xcode / DeriveData文件夹
  • “解体”豆荚
  • pod安装
  • 拖放react-native-code-push xcode项目/库直接到我的库中的xbox应用程序
  • xcode干净
  • 反应本地链接
  • 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

我的反应信息如下(它是一个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开发很新,但我上面所做的事情似乎应该解决问题,但事实并非如此。错误似乎很明显,但我不知道还能做什么。

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

ios objective-c xcode react-native
4个回答
0
投票

错误被触发at this line,只有在Swift项目中用作Pod时才需要

#import "React/RCTEventEmitter.h"   // Required when used as a Pod in a Swift project

问题似乎是由这个pull request引起的,我建议你使用与[email protected]兼容的最新版react-native 0.57

请尝试以下方法来解决问题

1)确保你正确配置你的PodfileSwift如果你使用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 [email protected]

关注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语句都失败了(意味着那些类不可用)并且line 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

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


0
投票

我有相同/类似的问题/ s将CodePush与RNPM和CocoapPods集成在一起。

我建议你手动安装它,option 3。它是第一次尝试。

我正在开展一个非常大的项目,并遇到过与iOS类似的问题。解决了我的问题是删除了构建服务器所在机器的“全局”缓存。另外,尝试删除Xcode Archives和Derived Data;和Podfile.lock。


0
投票

按照这个步骤

  1. 更新RNFirebase(如果不是最新版本)
  2. 关闭平行
  3. 在Xcode导航器中选择RNFirebase.xcodeproj
  4. 选择Build Phases选项卡
  5. 在Link Binary With Libraries下,添加Pods_{projectName}.framework文件

如果不工作打开并行并再试一次

您需要确保在RNFirebase之前构建Pod。


0
投票

必须以这种方式解决此问题:

  • 查找并删除AppCenter的所有引用(使用Cmd-F快捷方式)
  • 重新安装包
  • 从终端中的/ ... / ios / ... /文件夹运行pod install命令

希望这可以帮助。

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