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
相关推荐
lexiangqicheng3 小时前
rn入口文件setup.js解读
react native
sure2821 天前
react native 编写一个歌词组件
前端·react native
风景_fengjing2 天前
React Native + Expo搭建APP项目+安卓模拟器
react native·expo
pe7er4 天前
Reactnative 项目开发(最佳?)实践
react native
每天开心4 天前
从零开始:使用 Expo 构建你的第一个 React Native 应用
react native
冯志浩4 天前
React Native 状态管理 - useState
react native·掘金·金石计划
wayne2144 天前
ReactNative0.81版本发布
react native
木西5 天前
React Native DApp 开发全栈实战·从 0 到 1 系列(expo-router)
react native·web3·app
pe7er6 天前
React Native 多环境配置全攻略:环境变量、iOS Scheme 和 Android Build Variant
前端·react native·react.js
麦客奥德彪10 天前
解决 React Native iOS 与 OpenHarmony 开发环境冲突问题
react native·ios·harmonyos