如何从 React ^0.14.8 & React-native ^0.24.1 升级到 React 15.0.2 和 React-native 0.26.3

Posted

技术标签:

【中文标题】如何从 React ^0.14.8 & React-native ^0.24.1 升级到 React 15.0.2 和 React-native 0.26.3【英文标题】:How to upgrade from React ^0.14.8 & React-native ^0.24.1 to React 15.0.2 and React-native 0.26.3 【发布时间】:2016-10-03 15:15:57 【问题描述】:

我有 Xcode 版本 7.3.1 节点版本 v4.4.6 和 npm 版本 3.8.6

所以现在我的 ios React Native 应用程序正在构建没有问题,但我正在尝试使用库:https://github.com/aksonov/react-native-router-flux/blob/master/docs/MIGRATION.md

需要 React-native 版本 0.26.3

于是查了https://github.com/facebook/react-native/blob/0.26-stable/package.json,发现有稳定版的React-native 0.26.3和React 15.0.2

所以我在 package.json 中更改了我对项目的依赖项,并删除了我的 node_modules 文件夹并重新安装。

  "dependencies": 
    "react": "15.0.2",
    "react-native": "0.26.3",
    "react-native-sound": "^0.8.3",
    "react-redux": "^4.4.5",
    "redux": "^3.5.2",
    "redux-thunk": "^2.1.0"
  

但是我的应用程序不再工作,并且在启动时我不断收到此错误。我应该如何正确升级到 React 15?

ld: warning: object file (/Users/appollo_liu/Documents/workspace/laybium_workspace/laybium/ios/build/Build/Products/Debug-iphonesimulator/libRNSound.a(RNSound.o)) was built for newer iOS version (9.0) than being linked (7.0)
Undefined symbols for architecture x86_64:
  "std::terminate()", referenced from:
      ___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
  "___cxa_begin_catch", referenced from:
      ___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
  "___gxx_personality_v0", referenced from:
      -[RCTjavascriptContext initWithJSContext:onThread:] in libReact.a(RCTJSCExecutor.o)
      -[RCTJavaScriptContext init] in libReact.a(RCTJSCExecutor.o)
      -[RCTJavaScriptContext invalidate] in libReact.a(RCTJSCExecutor.o)
      _RCTNSErrorFromJSError in libReact.a(RCTJSCExecutor.o)
      +[RCTJSCExecutor runRunLoopThread] in libReact.a(RCTJSCExecutor.o)
      -[RCTJSCExecutor init] in libReact.a(RCTJSCExecutor.o)
      -[RCTJSCExecutor context] in libReact.a(RCTJSCExecutor.o)
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **


The following build commands failed:
    Ld build/Build/Products/Debug-iphonesimulator/laybium.app/laybium normal x86_64
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/laybium.app
An error was encountered processing the command (domain=LaunchServicesError, code=0):
The operation couldn’t be completed. (LaunchServicesError error 0.)
Launching org.reactjs.native.example.laybium
An error was encountered processing the command (domain=FBSOpenApplicationErrorDomain, code=4):
The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 4.)

【问题讨论】:

你看过this guide吗?你跑react-native upgrade了吗?它旨在更新新版本的 react native 附带的所有依赖项和文件。您必须进入并手动更正升级后覆盖的所有值。 升级无法响应原生 0.26 我正在尝试从 0.14 -> 0.26.3 【参考方案1】:

首先将您的 react-native 更新到较新的版本,然后在您的项目根目录中运行 react-native upgrade

【讨论】:

以上是关于如何从 React ^0.14.8 & React-native ^0.24.1 升级到 React 15.0.2 和 React-native 0.26.3的主要内容,如果未能解决你的问题,请参考以下文章

Express & React - 如何将我的 var 从一个 .js 转移到另一个

react-native - 图像需要来自 JSON 的本地路径

如何从 fetch 中获取 JSON 数据(react-native)

如何限制对 react-router 中路由的访问?

如何在 React 功能组件之间传递数据?

如何从我的嵌套函数中获取 Geolocation API 坐标并进入 React 状态?