React Native踩坑新建的RN0.64项目无法在xcode 12.5上打开
环境信息
运行命令:
npx react-native info
结果如下:
npx react-native info [20:34:42]
info Fetching system and libraries information...
System:OS: macOS 11.3CPU: (8) x64 Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHzMemory: 839.71 MB / 16.00 GBShell: 5.8 - /bin/zshBinaries:Node: 14.15.2 - /usr/local/bin/nodeYarn: 1.22.10 - /usr/local/bin/yarnnpm: 7.11.2 - /usr/local/bin/npmWatchman: Not FoundManagers:CocoaPods: 1.10.1 - /usr/local/bin/podSDKs:iOS SDK:Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4Android SDK:API Levels: 23, 28, 29, 30Build Tools: 28.0.3, 29.0.2, 30.0.3System Images: android-30 | Google APIs Intel x86 AtomAndroid NDK: Not FoundIDEs:Android Studio: 4.1 AI-201.8743.12.41.6953283Xcode: 12.5/12E262 - /usr/bin/xcodebuildLanguages:Java: 1.8.0_271 - /usr/bin/javacnpmPackages:@react-native-community/cli: Not Foundreact: 17.0.1 => 17.0.1react-native: 0.64.0 => 0.64.0react-native-macos: Not FoundnpmGlobalPackages:*react-native*: Not Found
报错如下:
** BUILD FAILED **
The following build commands failed:
CompileC /Users/itkey/Library/Developer/Xcode/DerivedData/speedrn-gdnmwquzchcterhjmywhtacsnjev/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper-Folly.build/Objects-normal/x86_64/DistributedMutex.o /Users/itkey/mac/rn/speedrn/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
FAIL: 1
解决办法
临时解决办法(简单粗暴)
修改/ios/Podfile
注释掉Flipper相关的内容。
# Enables Flipper.## Note that if you have use_frameworks! enabled, Flipper will not work and# you should disable the next line.#use_flipper!()#post_install do |installer|#react_native_post_install(installer)#end
这是一个临时解决办法,不知道后面会不会有什么隐患。实际上确实可以正常运行。
方法二(推荐)
修改/ios/Podfile
内容如下:
详细修改操作:
注释掉下面内容:
use_flipper!()post_install do |installer|react_native_post_install(installer)end
并把此处替换为:
#⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄修复iOS 14.5新建RN0.64无法运行⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄def find_and_replace(dir, findstr, replacestr)Dir[dir].each do |name|text = File.read(name)replace = text.gsub(findstr,replacestr)if text != replaceputs "Fix: " + nameFile.open(name, "w") { |file| file.puts replace }STDOUT.flushendendDir[dir + '*/'].each(&method(:find_and_replace))endpost_install do |installer|flipper_post_install(installer)find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h","atomic_notify_one(state)", "folly::atomic_notify_one(state)")find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h","atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")end
#⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃修复iOS 14.5新建RN0.64无法运行⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃
最终文件如下:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'platform :ios, '10.0'target 'speed2' doconfig = use_native_modules!use_react_native!(:path => config[:reactNativePath],# to enable hermes on iOS, change `false` to `true` and then install pods:hermes_enabled => false)target 'speed2Tests' doinherit! :complete# Pods for testingend# Enables Flipper.## Note that if you have use_frameworks! enabled, Flipper will not work and# you should disable the next line.#use_flipper!()#post_install do |installer|# react_native_post_install(installer)#end#⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄修复iOS 14.5新建RN0.64无法运行⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄def find_and_replace(dir, findstr, replacestr)Dir[dir].each do |name|text = File.read(name)replace = text.gsub(findstr,replacestr)if text != replaceputs "Fix: " + nameFile.open(name, "w") { |file| file.puts replace }STDOUT.flushendendDir[dir + '*/'].each(&method(:find_and_replace))endpost_install do |installer|flipper_post_install(installer)find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h","atomic_notify_one(state)", "folly::atomic_notify_one(state)")find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h","atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")end
#⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃修复iOS 14.5新建RN0.64无法运行⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃
end
总结
方法二最终实现思路就是修改这个文件达到修复无法启动的问题。
Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h
理论上等到Flipper-Folly文件更新以后,这个问题应该就会不存在了,期待它官方更新。
RN0.63.3测试
有网友评论0.63版本报错,我来实测一下。
创建0.63的项目
npx react-native init AwesomeProject --version 0.63.3
运行测试
不对Podfile做修改
报错如下:
修改/ios/Podfile
注释掉Flipper相关的内容。
- 修改
/ios/Podfile
注释掉Flipper相关的内容。 - 删除
/ios/Pod
目录 - 删除
/ios/Podfile.lock
- 执行
pod install --verbose
yarn ios
运行项目- 运行成功!
方法二修改/ios/Podfile
内容
- 修改
/ios/Podfile
修改后内容如下:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'platform :ios, '10.0'target 'AwesomeProject' doconfig = use_native_modules!use_react_native!(:path => config["reactNativePath"])target 'AwesomeProjectTests' doinherit! :complete# Pods for testingend# Enables Flipper.## Note that if you have use_frameworks! enabled, Flipper will not work and# you should disable these next few lines.#use_flipper!#post_install do |installer|# flipper_post_install(installer)#end#⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄修复iOS 14.5新建RN0.64无法运行⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄def find_and_replace(dir, findstr, replacestr)Dir[dir].each do |name|text = File.read(name)replace = text.gsub(findstr,replacestr)if text != replaceputs "Fix: " + nameFile.open(name, "w") { |file| file.puts replace }STDOUT.flushendendDir[dir + '*/'].each(&method(:find_and_replace))endpost_install do |installer|flipper_post_install(installer)find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h","atomic_notify_one(state)", "folly::atomic_notify_one(state)")find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h","atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")end#⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃修复iOS 14.5新建RN0.64无法运行⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃
endtarget 'AwesomeProject-tvOS' do# Pods for AwesomeProject-tvOStarget 'AwesomeProject-tvOSTests' doinherit! :search_paths# Pods for testingend
end
- 删除
/ios/Pod
目录 - 删除
/ios/Podfile.lock
- 执行
pod install --verbose
yarn ios
运行项目- 运行成功!
参考
https://github.com/facebook/react-native/issues/31179
https://github.com/facebook/flipper/issues/2215
https://github.com/facebook/react-native/issues/31179
React Native踩坑新建的RN0.64项目无法在xcode 12.5上打开相关推荐
- React Native填坑之旅--动画篇
React Native填坑之旅--Button篇 React Native填坑之旅--动画 React Native填坑之旅--HTTP请求篇 动画是提高用户体验不可缺少的一个元素.恰如其分的动画可 ...
- truffle unbox react 初始化踩坑
truffle unbox react 初始化踩坑 1.文件位置引起的错误 一定要在package.json 所在文件夹下npm run start ,新版本一定要进入client文件夹再npm ru ...
- React Native之React Navigation踩坑
自动重装系统之后,已经很长一段时间没有来写React Native了,今天空闲之余,决定重新配置React Native的开发环境,继续踩坑... React Native的开发环境配置狠简单,只要依 ...
- native react ssh_React Native踩坑笔记(持续更新中...)
最近发现市场上对React Native开发人员的需求挺多的,自己就想学习一下React Native,多一门技术,好将来买个好价位.嘿嘿! 在学习React Native中碰到了不少坑,再次记录下来 ...
- 超详细 React Native 入坑使用指南,我在元宇宙等你
前言 大家好,我是虚竹,今天给大家分享一下我是如何快速通关打怪搭建 React Native 跨端开发环境,并使用大家非常熟悉的开发工具 VSCode 来编写丝滑般的代码.编写丝滑般代码会再下一篇输出 ...
- React Native填坑之旅 -- 回归小插曲
回归RN,非常开心啊! 在React Native 0.49.5上开发,直接遇到一个ios模拟器的问题.这个问题很简单就是Bundle URL not present. 在网上找了很多的解决方法,都不 ...
- React Native+Node.js 开发的课程表app项目笔记
在做项目之前,首先要把React Native 的环境搭建好,这里我就不多做阐述,RN中文网步骤说的挺清楚的,就跟着配置就好. http://reactnative.cn/docs/0.... 一.总 ...
- React Native Expo开发的OW移动端项目
iOS演示 开源地址 GitHub Gitee 项目地址 Andorid 版 Android Expo 版(需 Expo 移动端(Android/iOS)) Expo 简介 项目基于Expo的 Rea ...
- [笔记]React+Cordova踩坑
之前做过一点前端的小项目所以前端还算熟练 因为最近在准备GRE所以想能不能写一个背单词软件 正好这学期有个Android开发课,就用来当大作业了 前端: webpack+react+redux 后端: ...
- Android踩坑日记:使用Fesco图片加载库在GridView上的卡顿优化
1,fresco是一个强大的图片加载库 2,fresco设计了一个叫做image pipeline(图片管道)的模块,它负责从从网络,从本地文件系统,从本地资源加载图片,为了最大限度节约资源和cpu时 ...
最新文章
- linux软件包管理详解
- PHP学习之没有权限修改hosts文件
- 查看目标网站--结构
- struts2教程--标签库详解
- 百度百科中关于fwrite的用法说明
- SAP UI5和Angularjs事件处理机制的实现比较
- 简易自动电阻测试仪_开始自动测试您的网站的简单方法
- 你精通excel吗?不,我精通python操控excel!
- 使用JDK中的 keytool【创建证书】・【查看】・【使用】
- ATC空管系统的实时控制软件系统分析
- php呼叫平台,什么是PHP运算符“?和“:”呼叫和他们做什么?
- 计算机设备维修与及日常保养,电脑主机日常的维护保养计划
- 那些烦人的VC++库、win10中的VC++库(全部)
- 201711671221第一周总结
- 语法长难句-----名词和名词性从句
- 解决Windows无法访问指定设备路径或文件,您可能没有合适的权限访问这个项目
- Android Studio 个性化主题配置。
- 轻松完成word格式的接口文档
- FFmpeg--一个操作视频音频的强大工具
- C++面向对象程序设计陈维兴版第四章所有例题
热门文章
- CPU内部看门狗,外部看门狗以及软件看门狗
- python歌词统计单词词频_python词频统计
- Ask for help
- 最新高级JAVA架构师之路(价值3万元+年薪百万计划)
- Python数据分析《黑客帝国》-一切都不是偶然
- vue-实现换一换功能
- Windows系统下快速安装、配置Aira2,及图形界面配置、度盘、B站视频下载
- 2019会考计算机知识点,2019-2020年高中信息技术高一会考总复习理论知识点汇总整理...
- html5经典教程,40个经典HTML5实例教程.pdf
- 计算机教案word格式模板,大学授课教案模板Word格式