react native 遇到的坑汇总篇

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/rth362147773/article/details/80729405

问题一

iOS:编译错误Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/b

解决方法如下:

在Build Settings 中,
将Apple LLVM compiler 4.1 - Language 中的
c++Standard Library 修改为 
libstdc++(GNU C++ standard library)

问题二

iOS错误 library not found for -lXXX
在react-native中的情况会不一样。

1.先搜索lXXX,我这边是RCTlipay。

2.然后在node_modules/react-native-alipay/ios/RCTAlipay 查看文件是否存在。

如果存在就排除react-native-alipay文件丢失问题。

npm install react-native-alipay

文件存在那么只需要再次绑定 就可以了

react-native link react-native-alipay

问题三

iOS错误 The executable was signed with invalid entitlements.
能使用模拟器,但无法在真机调试。是因为真机包需要证书才行。

问题解决:
1.证书是否有效。
2.排除第一点后,可以从新把证书删除再重新操作。

问题四

error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..

> Task :app:generateBundledResourcesHashRelease
77e6e86e7395e480f9306d31f8921133fc767d658c06f8a18d37f8ba621f9ba5

/Users/wangwenjie/project/locals/locals-framework-master-plus/android/app/build/intermediates/res/merged/rel
ease/drawable-xhdpi/node_modules_reactnavigation_src_views_assets_backicon.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to process resources, see aapt output above for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

问题解决:
gradle.properties 添加 android.enableAapt2=false

这显然与AAPT2问题,AAPT2是Gradle工具3.0中的新版本,
android.enableAapt2=false它实质上使用旧的aapt来获取资源。

问题五

/ios/bundle/index.ios.jsbundle: No such file or directory
这里写图片描述

问题解决:
修改AppDelegate.m中的jsCodeLocation,设置jsCodeLocation指向本地main.jsbundle文件

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"index.ios" withExtension:@"jsbundle"];

生成index.ios.jsbundle文件

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

持续补充。。。

猜你喜欢

转载自blog.csdn.net/rth362147773/article/details/80729405