1. 安装Git
2. 安装react-native-git-upgrade
工具模块
npm install -g react-native-git-upgrade
react-native-git-upgrade
提供了豪华的一条龙自动合并更新流程,主要包含两个服务:
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的官方代码。然后你可以根据实际情况判断,选择某一方晋级,另一方出局.
原文链接:https://www.f2er.com/react/302582.html