react native 安裝及初始化工程
1、npx 安裝太慢解決辦法
https://blog.csdn.net/m0_46423830/article/details/140628277
npm config set registry https://registry.npmmirror.com
2、搭建環(huán)境
https://reactnative.dev/docs/set-up-your-environment
3、創(chuàng)建工程
npx @react-native-community/cli init <project_name>
4、解決bundle install太慢的問題
bundle config mirror.https://rubygems.org https://gems.ruby-china.com
5、在ios模擬器上運行
https://reactnative.cn/docs/running-on-simulator-ios
啟動模擬器?
當你完成了初始化 React Native 新項目后,就可以在項目目錄下運行npx react-native run-ios來啟動模擬器。如果一切配置都沒有問題,應該很快就能看到你的應用在 iOS 模擬器上運行起來。
指定模擬的設備類型?
你可以使用--simulator參數(shù),在其后加上要使用的設備名稱來指定要模擬的設備類型。如果你要模擬 iPhone 15,那么這樣運行命令即可:
npx react-native run-ios --simulator "iPhone 15"。
注意:隨著RN和Xcode版本迭代更新,默認和可選的模擬設備可能有變化。
你可以在終端中運行xcrun simctl list devices來查看具體可用的設備名稱。
xcrun simctl list devices
== Devices ==
-- iOS 17.5 --
iPhone 15 (xxxxxx) (Shutdown)
iPhone 15 Plus (xxxxxx) (Shutdown)
iPhone 15 Pro (xxxxxx) (Shutdown)
iPhone 15 Pro Max (xxxxxx) (Shutdown)
iPad (10th generation) (xxxxxx) (Shutdown)
iPad mini (6th generation) (xxxxxx) (Shutdown)
yarn run ios --simulator "iPhone 15 Pro"
在這里你可以寫你想要的版本。
官方參考:Using TypeScript · React Native
6、構建apk包
https://reactnative.cn/docs/signed-apk-android
進入項目根目錄下的`android`文件夾,在當前目錄打開終端,然后輸入./gradlew assembleRelease開始發(fā)布APK的Release版
adb install ./android/app/build/outputs/apk/release/app-release.apk
7、JavaScript 基礎知識
https://zh.javascript.info/first-steps
8、React 快速入門
https://zh-hans.react.dev/learn
浙公網(wǎng)安備 33010602011771號