React Native Semantic 问题:重新定义“MethodDescriptor”

Eme*_*pes 1 react-native react-native-ios

该应用程序反应本机应用程序在模拟器上编译一切正常,但是当我尝试从 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;
};
Run Code Online (Sandbox Code Playgroud)

} }

小智 5

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