# RNApp
**Repository Path**: gdoudeng/RNApp
## Basic Information
- **Project Name**: RNApp
- **Description**: RN项目模板,react-native(0.79.2) + react-navigation + typescript + redux + immer
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-05-28
- **Last Updated**: 2025-05-28
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
# Getting Started
> **Note**: Make sure you have completed the [Set Up Your Environment](https://reactnative.dev/docs/set-up-your-environment) guide before proceeding.
## Step 1: Start Metro
First, you will need to run **Metro**, the JavaScript build tool for React Native.
To start the Metro dev server, run the following command from the root of your React Native project:
```sh
# Using npm
npm start
# OR using Yarn
yarn start
```
## Step 2: Build and run your app
With Metro running, open a new terminal window/pane from the root of your React Native project, and use one of the following commands to build and run your Android or iOS app:
### Android
```sh
# Using npm
npm run android
# OR using Yarn
yarn android
```
### iOS
For iOS, remember to install CocoaPods dependencies (this only needs to be run on first clone or after updating native deps).
The first time you create a new project, run the Ruby bundler to install CocoaPods itself:
```sh
bundle install
```
Then, and every time you update your native dependencies, run:
```sh
bundle exec pod install
```
For more information, please visit [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html).
```sh
# Using npm
npm run ios
# OR using Yarn
yarn ios
```
If everything is set up correctly, you should see your new app running in the Android Emulator, iOS Simulator, or your connected device.
This is one way to run your app — you can also build it directly from Android Studio or Xcode.
## Step 3: Modify your app
Now that you have successfully run the app, let's make changes!
Open `App.tsx` in your text editor of choice and make some changes. When you save, your app will automatically update and reflect these changes — this is powered by [Fast Refresh](https://reactnative.dev/docs/fast-refresh).
When you want to forcefully reload, for example to reset the state of your app, you can perform a full reload:
- **Android**: Press the R key twice or select **"Reload"** from the **Dev Menu**, accessed via Ctrl + M (Windows/Linux) or Cmd ⌘ + M (macOS).
- **iOS**: Press R in iOS Simulator.
## Congratulations! :tada:
You've successfully run and modified your React Native App. :partying_face:
### Now what?
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
- If you're curious to learn more about React Native, check out the [docs](https://reactnative.dev/docs/getting-started).
# Troubleshooting
If you're having issues getting the above steps to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
# Learn More
To learn more about React Native, take a look at the following resources:
- [React Native Website](https://reactnative.dev) - learn more about React Native.
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
# 创建项目
- java 17
- node 18
又跟以前不一样了
> https://reactnative.dev/docs/getting-started-without-a-framework#step-1-creating-a-new-application
使用 `jenv` 设置这个项目下运行 `java` 都用 `17.0` 的
```bash
jenv local 17.0
```
新建项目了,指定版本号的话就带上 `version` 参数
```bash
npx @react-native-community/cli@latest init RNApp
npx @react-native-community/cli@X.XX.X init AwesomeProject --version X.XX.X
```
# 运行
## `Android`
> https://reactnative.dev/docs/running-on-device?platform=android
如果直接 `yarn android` 报错的话,那么先用 `as` 打开项目运行一遍,然后再运行 `yarn android`
## `iOS`
> https://reactnative.dev/docs/running-on-device?platform=ios
## ios原生库安装
这个也跟以前不一样了, 以前是用 `pod install` 安装的,现在是用 `bundle` 安装的
1. `cd ios` 导航到 `ios` 文件夹。
2. `bundle install` 安装 `Bundler`
3. `bundle exec pod install` 安装由 `CocoaPods` 管理的 `iOS` 依赖项。
只要 `Gemfile` 没改, 都不需要重复执行 `bundle install`。
### 安装 `SocketRocket` 失败
> https://github.com/facebook/react-native/issues/38300
CocoaPods could not find compatible versions for pod "SocketRocket"
- 解决方法
运行 `bundle exec pod install --repo-update`
## 然后再运行
直接 `xcode` 打开项目运行,这个要设置签名啥的,用命令行会报错
# 调试
> https://reactnative.dev/docs/debugging#opening-devtools
以前那个 `react-native-debugger` 有点问题,现在用自带的调试器
启动服务后,直接在控制台按 `j` 即可
## 调试 `redux` 的时候,需要用这个工具 `reactotron`
> https://github.com/infinitered/reactotron/blob/master/docs/quick-start/react-native.md#installing-reactotronapp
打开了 `reactotron` 后,先反转一下端口,然后刷新一下 `app` ,理论上就连上了
```bash
adb reverse tcp:9090 tcp:9090
```
# 发布到谷歌
```
npx react-native build-android --mode=release
```
生成的 AAB 可以在 android/app/build/outputs/bundle/release/app-release.aab 下找到,并且可以上传到 Google Play。
# 测试应用程序的发布版本
```
yarn android --mode release
yarn ios --mode Release
```