【问题标题】:Duplicate interface definition for class 'RCTBridge' error after react-native linkreact-native 链接后类“RCTBridge”错误的重复接口定义
【发布时间】:2018-05-15 21:44:33
【问题描述】:

在我的 package.json 中做一个 react-native 链接来链接字体资产之后:

"rnpm": {
   "assets": ["./assets/fonts/"]
}

在尝试运行 react-native run-ios 时,我在 xcode 中遇到了几个错误:

类“RCTBridge”的重复接口定义

这似乎是包含文件的问题,如果你们有任何线索..

谢谢

【问题讨论】:

    标签: ios react-native react-native-linking


    【解决方案1】:

    我有同样的问题。

    在我的情况下,添加 react-native-fabric 库后会出现问题。
    所以我正在执行以下步骤。

    1) 打开 SMXAnswers.h 然后将 #import "RCTBridgeModule.h" 更改为

    #if __has_include(<React/RCTBridgeModule.h>)
    #import <React/RCTBridgeModule.h>
    #else
    #import "RCTBridgeModule.h"
    #endif
    

    2) 打开 SMXAnswers.m 然后更改如下

    #import "RCTBridgeModule.h"  
    #import "RCTEventDispatcher.h"  
    #import "RCTBridge.h"
    

    #if __has_include(<React/RCTBridgeModule.h>)
    #import <React/RCTBridgeModule.h>
    #else
    #import "RCTBridgeModule.h"
    #endif
    
    #if __has_include(<React/RCTBridge.h>)
    #import <React/RCTBridge.h>
    #else
    #import "RCTBridge.h"
    #endif
    
    #if __has_include(<React/RCTEventDispatcher.h>)
    #import <React/RCTEventDispatcher.h>
    #else
    #import "RCTEventDispatcher.h"
    #endif
    

    这可能会解决您的问题。
    这个解决方案对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      • 2020-10-07
      相关资源
      最近更新 更多