应用程序 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/