React native 常见问题

本文档记录了在使用React Native开发过程中遇到的一些常见问题及解决方法,包括运行应用时的log错误、新建项目运行失败、RCTBridgeModule.h找不到、报错command /bin/sh failed、'boost/iterator/iterator_adaptor.hpp'文件未找到以及react-navigation与列表组件配合使用的问题。通过修改配置、降级依赖、清理缓存、添加引用等方式,可以解决这些问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

##react native 常见问题记录


#### 1. react-native 运行应用xcode打印log__nw_connection_get_connected_socket_block_invoke Connection has no connected handler

		1. Xcode menu -> Product -> Edit Scheme...
		2. Environment Variables -> Add -> Name: "OS_ACTIVITY_MODE", Value:"disable"
		3. Run your app again, done! 这样就没问题了

#### 2. 新建RN项目,运行不了,提示Print:Entry,":CFBundleIdentifier",Does Not Exist
	该问题记录于(2017/6/12),是因为react-native更新了新版本0.45导致的一个bug吧,后面官方应该会解决这个问题!
	
	解决方案是,降级回老版本!
	
	1. 修改package.json 文件
	
			"dependencies": {
				"react": "16.0.0-alpha.6",
				"react-native": "0.44.0"
			},
			"devDependencies": {
				"babel-jest": "20.0.0",
				"babel-preset-react-native": "1.9.2",
				"jest": "20.0.4",
				"react-test-renderer": "16.0.0-alpha.6"
			},
	2. 删掉原来的node_modules整个文件夹,然后
			
			npm install


#### 3.RCTBridgeModule.h file not found

1. 修改

		#import "RCTBridgeModule.h"
		换为		
		#import <React/RCTBridgeModule.h>

2. 如果还是提示

		React/RCTBridgeModule.h file not found
		
	* 在Xcode 项目设置界面中 Header Search Paths 中添加$(SRCROOT)/../node_modules/react-native/React
	* 如果不懂Header Search Paths 配置路径,百度一下咯

#### 4. 报错 command /bin/sh failed with exit code 1 
    
解决方法:项目->Build Phases->Bundle React Native code and images -> 勾选 Run script only when installing



#### 5. 'boost/iterator/iterator_adaptor.hpp' file not found

* 产生原因:

	/Users/Vanessa/.rncache 中 boost_1_63_0.tar.gz, double-conversion-1.1.5.tar.gz, folly-2016.09.26.00.tar.gz, glog-0.3.4.tar.gz 文件下载不完整
node_modules/react-native/third-party 文件不完整

* 解决方案:

	删除 .rncache 后重新下载,或[手动下载](https://pan.baidu.com/s/1geLl5tT)后放入 .rncache 中
把以上文件解压后放入 node_modules/react-native/third-party 下
Clean & Build


#### 6. react-navigation 与 SectionList、listView、flatlist等配合使用,不能展示视图,要拉一下才能显示出来

* 解决方法1:

	添加这个属性 removeClippedSubviews={false}

* 解放方法2:
	
	flex:1  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值