ReactNative版本升级

基于Git的自动合并更新

重要提示: 现在你不需要运行npm install去下载新版本的React Native了,按照下面的步骤即可自动进行更新。

1. 安装Git

你需要安装Git,但这并不要求你自己使用Git去管理项目。只是我们的更新过程会使用到Git罢了。你可以在这里下载安装Git,注意要把git的路径添加到PATH变量中。

2. 安装react-native-git-upgrade工具模块

$ npm install -g react-native-git-upgrade

react-native-git-upgrade提供了豪华的一条龙自动合并更新流程,主要包含两个服务:

  • 首先它会利用Git工具计算新旧版本文件间的差异并生成补丁
  • 然后在用户的项目文件上应用补丁

3. 运行更新命令

$ react-native-git-upgrade
# 这样会直接把react native升级到最新版本

# 或者是:

$ react-native-git-upgrade X.Y.Z
# 这样把react native升级到指定的X.Y.Z版本

升级过程会如丝般顺滑。当然在少数情况下,取决于具体的版本和你修改的程度,Git的合并算法也可能遭遇失败产生一些冲突,需要你人工介入。

4. 解决冲突

文件中的冲突会以分隔线隔开,并清楚的标记出处,例如下面这样:

13B07F951A680F5B00A75B9A /* Release */ = {
  isa = XCBuildConfiguration;
  buildSettings = {
    ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
<<<<<<< ours
    CODE_SIGN_IDENTITY = "iPhone Developer";
    FRAMEWORK_SEARCH_PATHS = (
      "$(inherited)",
      "$(PROJECT_DIR)/HockeySDK.embeddedframework",
      "$(PROJECT_DIR)/HockeySDK-iOS/HockeySDK.embeddedframework",
    );
=======
    CURRENT_PROJECT_VERSION = 1;
>>>>>>> theirs
    HEADER_SEARCH_PATHS = (
      "$(inherited)",
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
      "$(SRCROOT)/../node_modules/react-native/React/**",
      "$(SRCROOT)/../node_modules/react-native-code-push/ios/CodePush/**",
    );

上面代码中的"ours"表示你自己的代码,而"theirs"表示React Native的官方代码。然后你可以根据实际情况判断,选择某一方晋级,另一方出局

5.ios升级之后的问题解决

(1)'boost/iterator/iterator_adaptor.hpp' file not found(0.44升级到新版本)

Description

iOS build fails on newly created react-native project on 0.45.0.

Reproduction Steps and Sample Code

$ react-native init boostless
$ cd boostless
$ react-native run-ios

Truncated result:

** BUILD FAILED **


The following commands produced analyzer issues:
	Analyze /Users/<MASKED>/boostless/node_modules/react-native/ReactCommon/yoga/yoga/YGNodeList.c
	Analyze /Users/<MASKED>/boostless/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.c
(2 commands with analyzer issues)

The following build commands failed:

	PhaseScriptExecution Install\ Third\ Party /Users/<MASKED>/boostless/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/boostless.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/boostless.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

解决办法

It's a work around:
Download+extract boost 1.63 and copy to node_modules/react-native/third-party/boost_1_63_0

Additional Information

  • React Native version: 0.45.0
  • Platform: iOS
  • Development Operating System: macOS Sierra, 10.12.5
  • Dev tools: Xcode 8.3.2 (8E2002)

参考github issue

猜你喜欢

转载自blog.csdn.net/qq_30817073/article/details/78042057