reactNative0.71版本的使用

开发环境配置

参考reactNative 官网 版本选中0.71

打包配置

1. IOS

打开项目 -> 进入ios目录->执行命令 pod install ->项目名称.xcworkspace -> 使用xcode打开->配置证书

证书配置截图如下

💡tips:TARGETS目录下会有多个文件(以test tvos结尾的文件)根据项目要求保留,本项目不需要单元测试和tvos可以删除,多余的文件可能会导致打包不成功的情况

2. andorid
  • 配置打包快捷操作

初始配置

  1. 网络配置(http)

在ios9和android9开始默认使用https,但是由于后台有可能使用http协议,我们需要在原始的项目中配置http,如果不配置http,打包后app会变成炫酷的白屏以及网络失败

    1. android在debug模式下,是默认开启http,build模式下默认不开启

复制 android:usesCleartextTraffic="true"放在main AndroidManifest.xml 下

    1. ios默认开启了http协议

tips:这是reactNative生成的,很可能上架的时候被拦截,不让上架,这时候就需要单独配置域名

  1. 启动屏

启动屏采用的是react-native-splash-screen 根据文档就能使用app的启动屏,但是其中有一个bug如图:

在新版中采用如下代码,会使app.js中的启动屏不会消失

  1. 权限

在ios启动app时,会报: No permission handler detected

package.json 文件

复制代码
"reactNativePermissionsIOS": [
    "AppTrackingTransparency",
    "BluetoothPeripheral",
    "Calendars",
    "Camera",
    "Contacts",
    "FaceID",
    "LocationAccuracy",
    "LocationAlways",
    "LocationWhenInUse",
    "MediaLibrary",
    "Microphone",
    "Motion",
    "Notifications",
    "PhotoLibrary",
    "PhotoLibraryAddOnly",
    "Reminders",
    "Siri",
    "SpeechRecognition",
    "StoreKit"
  ],

需要执行 npx react-native setup-ios-permissions 然后cd ios 执行 pod install

执行以下命令清除Xcode Derived Data

复制代码
rm -rf ~/Library/Developer/Xcode/DerivedData
相关推荐
哼唧唧_10 小时前
使用 React Native 开发鸿蒙(HarmonyOS)运动健康类应用的系统化准备工作
react native·react.js·harmonyos·harmony os5·运动健康
哼唧唧_2 天前
React Native开发鸿蒙运动健康类应用的项目实践记录
react native·harmonyos·harmony os5·运动健康
程序员小刘2 天前
鸿蒙【HarmonyOS 5】 (React Native)的实战教程
react native·华为·harmonyos
烈焰晴天3 天前
使用ReactNative加载Svga动画支持三端【Android/IOS/Harmony】
android·react native·ios
哼唧唧_3 天前
使用 React Native 开发鸿蒙运动健康类应用的高频易错点总结
react native·react.js·harmonyos·harmony os5·运动健康
鄂鱼3 天前
使用react-native-skia实现自绘地图实践与踩坑记录
react native
依旧004 天前
react native webview加载本地HTML,解决iOS无法加载成功问题
react native·ios·html·vite·webview
不想当reducer4 天前
React Native 阿里云 OSS 上传实战:从相册资源处理到动态签名管理
前端·javascript·react native
hellokai4 天前
ReactNative介绍及简化版原理实现
android·react native
哼唧唧_6 天前
基于React Native开发鸿蒙新闻类应用的实战开发笔记
react native·华为·新闻·harmony os5