ReactNative 常见问题

821 阅读1分钟

1. React Native CFBundleIdentifier Not Exist

后面终于找到了原因 node_modules/react-native/ios-install-third-party.sh执行结果不正确,可能是网络原因。

手动下载

1.放进 ~/.rncache/. 2.解压到node_modules/react-native/third-party/

在xcode中运行,会发现报错,缺少glob config.h 1.进入终端cd node_modules/react-native/third-party/glog-0.3.4 2.运行../../scripts/ios-configure-glog.sh 会发现脚本帮忙生成了很多东西,包括config.h

2. Unknown argument type 'attribute' in method -[RCTUIManager setJSResponder:blockNativeResponder:]. Extend RCTConvert to support this type.

路径: 项目/node_modules/react-native/React/Base/RCTModuleMethod.mm. (或者.m)文件 找到 static BOOL RCTParseUnused 这个方法 替换成

static BOOL RCTParseUnused(const char **input) { return RCTReadString(input, "__unused") || RCTReadString(input, "attribute((unused))") || RCTReadString(input, "attribute((unused))"); }

3. The app’s Info.plist must contain an NSMicrophoneUsageDescription key

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

1.在项目中找到info.plist文件,右键点击以 Source Code形式打开 2.添加以下键值对,这里以 PhotoLibrary 作为例子

<key>NSPhotoLibraryUsageDescription</key>
<string>此 App 需要您的同意才能读取媒体资料库</string>

4. IOS打包

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output release_ios/main.jsbundle --assets-dest release_ios/

5. failed to resolve com.android.support:appcompat-v7:23+ 解决方法

这个原因多半是因为Android SDK Tools 的版本与Android SDK Build Tools 的版本不一致造成的,查找原因方法:点开SDKmanager

在查看module中的build.gradle文件

module中的build.gradle文件中标记的两处改成对应的Android SDK tools 的版本;如我的是26;然后try again 编译通过;

参考链接:blog.csdn.net/wangqiang82…