React Native CLI 初始建立專案
-
iOS 環境需求
Node v19.5.0
Ruby v2.7.5(用 rbenv
去安裝)
mac 預設是 2.6.8,會遇到下面錯誤訊息,需要升級 Ruby 版本才可以使用
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
使用 Homebrew 安裝 Ruby 2.7.5 方式:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Xcode
14.0.1
CocoaPods
1.11.3
Watchman(Options)
2023.02.20.00
-
Android 環境需求
Java (可以用 brew 安裝 Zulu OpenJDK)
Android Studio 需要包含以下項目
Android SDK
Android SDK Platform
Android Virtual Device
進入 Android Studio 安裝 Android 12
( SDK Manager )
設定電腦環境 ANDROID_HOME
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
-
iOS 及 Android 環境配置好後,就可以使用 RN CLI 建立專案
npx react-native@0.71.4 init <ProjectName>
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
運行 Android 專案
npx react-native run-android
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
運行 iOS 專案
npx react-native run-ios
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
運行專案時,會開啟 Metro,不要關閉它
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 或是可以直接啟動 Metro,再按下 i / a 運行 ios 或是 android 專案
npm start
r - reload the app
d - open developer menu
i - run on iOS
a - run on Android