react-native - React Native 语义问题 : Redefinition of 'MethodDescriptor'

标签 react-native react-native-ios

应用程序 react native 应用程序在模拟器上编译一切正常但是当我尝试从 xcode 在我的 iphone 上运行它时我得到这些错误:

语义问题:

1 - “MethodDescriptor”的重新定义 - 在路径/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp:10 包含的文件中:

2 - “NativeModule”的重新定义 - 1. 在 react-path/native/ReactCommon/cxxreact/ModuleRegistry.cpp:10 包含的文件中:

代码就不错 React-cxxreact/NativeModule.h

// Copyright (c) Facebook, Inc. and its affiliates.

// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.

#pragma once

#include <string>
#include <vector>

#include <folly/Optional.h>
#include <folly/dynamic.h>

namespace facebook {
namespace react {

struct MethodDescriptor {
  std::string name;
  // type is one of js MessageQueue.MethodTypes
  std::string type;

  MethodDescriptor(std::string n, std::string t)
      : name(std::move(n))
      , type(std::move(t)) {}
};

  using MethodCallResult = folly::Optional<folly::dynamic>;

class NativeModule {
 public:
  virtual ~NativeModule() {}
  virtual std::string getName() = 0;
  virtual std::vector<MethodDescriptor> getMethods() = 0;
  virtual folly::dynamic getConstants() = 0;
  virtual void invoke(unsigned int reactMethodId, folly::dynamic&& params, int callId) = 0;
  virtual MethodCallResult callSerializableNativeHook(unsigned int reactMethodId, folly::dynamic&& args) = 0;
};

}

最佳答案

我通过终端执行“pod install”命令解决了这个问题,然后在 Xcode 中清理并重建我的项目。

关于react-native - React Native 语义问题 : Redefinition of 'MethodDescriptor' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58673197/

相关文章:

ios - 自从升级到 Xcode 10.2 我不能再通过 cli 运行 react-native run-ios

android - React Native 分享文件或链接

react-native - 尝试使用 'Animated' 使我的 SVG 元素旋转,但它不起作用

ios - React Native 应用程序在 iOS TestFlight 上立即崩溃

react-native - 未找到 React/RCTDefines.h' 文件(RN0.61)

javascript - 将函数添加到队列中以便稍后执行。终极版

javascript - 在返回的map()对象中设置图像

android - React-native + Relay.js 的稳定构建

ios - 在 iOS 应用程序启动期间,React Native 链接 URL 返回 null

react-native - 如何在React Native中设置本地文件夹图像