React-Native 遇到坑,方法总结

1:Print: Entry, ":CFBundleIdentifier", Does Not Exist

方法1,初始化的,指定项目版本(不推荐)
 react-native init MyAppName --version 0.44.3
方法2,更新RN 0.45以上版本所需的第三方编译boost库。boost链接地址

2:IOS编译时报错:'RCTAnimation/RCTValueAnimatedNode.h' file not found, 'fishhook/fishhook.h' file not found

方法1:每次重新生成node_modules文件夹,都需要修改一次(不推荐)
#import <RCTAnimation/RCTValueAnimatedNode.h>
把修改为
#import "RCTValueAnimatedNode.h"
方法2:执行 npm run postinstall 修复。

3:使用react-native时按cmd+r不能刷新模拟器

把模拟器的键盘尝试呼起就行。如下图所示
20170111141824843.png

4:使用react-native时按cmd+d 没有显示debug的调试按钮

ios在podfile文件中,加入 'DevSupport'。如图所示
屏幕快照 2017-12-12 下午5.31.29.png

5:react-native link 的 Error: Cannot read property 'match' of undefined"

ios在podfile文件中,加入 ' # Add new pods below this line
屏幕快照 2017-12-12 下午5.31.29.png

'。如图所示!

6:老项目加入RN,解决首次加载会出现白屏的优化。 在程序启动的时候执行 RNRootViewController.preLoad()
class RNRootViewController: MLViewController, UIGestureRecognizerDelegate {

    static var bridge: RCTBridge?
    private var rootView: RCTRootView!

    static func preLoad() {
        let jsCodeLocation = URL(string: "http://localhost:8081/index.bundle?platform=ios")
        RNRootViewController.bridge = RCTBridge(bundleURL: jsCodeLocation,
                                                moduleProvider: nil,
                                                launchOptions: nil)
        _ = RNRootViewController(moduleName: "customerService", params: nil)
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容