0

我在反应本机应用程序中使用代码推送,但在编译时出错,

项目中的 pod 版本

# React Native requirements
pod 'React', :path => '../node_modules/react-native', :subspecs => [
   'Core',
   'CxxBridge', # Include this for RN >= 0.47
   'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
   'RCTText',
   'RCTNetwork',
   'RCTWebSocket', # Needed for debugging
   'RCTAnimation', # Needed for FlatList and animations running on native UI thread
   # Add any other subspecs you want to use in your project
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

package.json

"react-native-code-push": "^5.7.0",
 "react": "16.8.3",
"react-native": "0.59.8",

我得到的错误

 [![Undefined symbols for architecture x86_64:
      "_JSObjectGetPrototype", referenced from:
          facebook::jsc::JSCRuntime::createFunctionFromHostFunction(facebook::jsi::PropNameID const&, unsigned int, std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>)::HostFunctionMetadata::initialize(OpaqueJSContext const*, OpaqueJSValue*) in libReact.a(JSCRuntime.o)
      "_JSObjectSetPrototype", referenced from:
          facebook::jsc::JSCRuntime::createFunctionFromHostFunction(facebook::jsi::PropNameID const&, unsigned int, std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>)::HostFunctionMetadata::initialize(OpaqueJSContext const*, OpaqueJSValue*) in libReact.a(JSCRuntime.o)
      "_JSPropertyNameAccumulatorAddName", referenced from:
          facebook::jsc::JSCRuntime::createObject(std::__1::shared_ptr<facebook::jsi::HostObject>)::HostObjectProxy::getPropertyNames(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSPropertyNameAccumulator*) in libReact.a(JSCRuntime.o)
      "_JSObjectCopyPropertyNames", referenced from:
          facebook::jsc::JSCRuntime::getPropertyNames(facebook::jsi::Object const&) in libReact.a(JSCRuntime.o)
      "_JSContextGetGlobalObject", referenced from:
          facebook::jsc::JSCRuntime::global() in libReact.a(JSCRuntime.o)
          facebook::jsc::JSCRuntime::createFunctionFromHostFunction(facebook::jsi::PropNameID const&, unsigned int, std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>)::HostFunctionMetadata::initialize(OpaqueJSContext const*, OpaqueJSValue*) in libReact.a(JSCRuntime.o)
      "_JSValueMakeString", referenced from:
          facebook::jsc::JSCRuntime::valueRef(facebook::jsi::Value const&) in libReact.a(JSCRuntime.o)
          facebook::jsc::JSCRuntime::createFunctionFromHostFunction(facebook::jsi::PropNameID const&, unsigned int, std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>)::HostFunctionMetadata::initialize(OpaqueJSContext const*, OpaqueJSValue*) in libReact.a(JSCRuntime.o)
      "_JSValueIsNumber", referenced from:
          facebook::jsc::JSCRuntime::createValue(OpaqueJSValue const*) const in libReact.a(JSCRuntime.o)
      "_JSClassCreate", referenced from:
          facebook::jsc::JSCRuntime::createObject(std::__1::shared_ptr<facebook::jsi::HostObject>)::$_0::operator()() const in libReact.a(JSCRuntime.o)
          facebook::jsc::JSCRuntime::createFunctionFromHostFunction(facebook::jsi::PropNameID const&, unsigned int, std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>)::$_1::operator()() const in libReact.a(JSCRuntime.o)
      "_JSObjectGetPropertyAtIndex", referenced from:
          facebook::jsc::JSCRuntime::getValueAtIndex(facebook::jsi::Array const&, unsigned long) in libReact.a(JSCRuntime.o)
      "_JSObjectMakeArray", referenced from:
          facebook::jsc::JSCRuntime::createArray(unsigned long) in libReact.a(JSCRuntime.o)
      "_JSEvaluateScript", referenced from:
          facebook::jsc::JSCRuntime::evaluateJavaScript(std::__1::unique_ptr<facebook::jsi::Buffer const, std::__1::default_delete<facebook::jsi::Buffer const> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libReact.a(JSCRuntime.o)
      "_JSValueIsUndefined", referenced from:
          facebook::jsc::JSCRuntime::createValue(OpaqueJSValue const*) const in libReact.a(JSCRuntime.o)
      "_JSPropertyNameArrayGetCount", referenced from:
          facebook::jsc::JSCRuntime::getPropertyNames(facebook::jsi::Object const&) in libReact.a(JSCRuntime.o)
      "_JSPropertyNameArrayGetNameAtIndex", referenced from:
          facebook::jsc::JSCRuntime::getPropertyNames(facebook::jsi::Object const&) in libReact.a(JSCRuntime.o)
      "_JSPropertyNameArrayRelease", referenced from:
          facebook::jsc::JSCRuntime::getPropertyNames(facebook::jsi::Object const&) in libReact.a(JSCRuntime.o)
      "_JSValueMakeUndefined", referenced from:
          facebook::jsc::JSCRuntime::valueRef(facebook::jsi::Value const&) in libReact.a(JSCRuntime.o)][1]][1]

在此处输入图像描述

4

2 回答 2

1

以下步骤对我有用;

cd ios
rm -rf Pods Podfile.lock
pod cache clean --all
pod install --repo-update

完成此行后,您可以再次尝试运行您的项目。

下面还有另一种解决方案;

watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start --reset-cache
于 2019-10-24T13:34:56.403 回答
0

SSZipArchive将from的版本更改2.1.x2.2.xonCodePush.podspec对我有用。

为了跟踪我的项目的这种变化,我使用了patch-package

  1. 打开node_modules/react-native-code-push/CodePush.podspec并将SSZipArchivefrom的版本更改~> 2.1~> 2.2
s.dependency 'SSZipArchive', '~> 2.2' # Like this
  1. 生成补丁:
$ yarn patch-package react-native-code-push

补丁文件应如下所示:

diff --git a/node_modules/react-native-code-push/CodePush.podspec b/node_modules/react-native-code-push/CodePush.podspec
index dca6e84..0b8928d 100644
--- a/node_modules/react-native-code-push/CodePush.podspec
+++ b/node_modules/react-native-code-push/CodePush.podspec
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
   # we explicitly let CocoaPods pull in the versions below so all dependencies are resolved and 
   # linked properly at a parent workspace level.
   s.dependency 'React'
-  s.dependency 'SSZipArchive', '~> 2.1'
+  s.dependency 'SSZipArchive', '~> 2.2'
   s.dependency 'JWT', '~> 3.0.0-beta.7'
   s.dependency 'Base64', '~> 1.1'
 end
  1. 提交补丁:
$ git add patches/react-native-code-push+5.7.0.patch
$ git commit -m "patch(react-native-code-push): bump SSZipArchive to 2.2.x"

而已。

注意:我正在使用 React Native0.61.2和代码推送5.7.0

于 2019-10-24T19:56:46.487 回答