> For the complete documentation index, see [llms.txt](https://twins-bamboo.gitbook.io/react-native-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://twins-bamboo.gitbook.io/react-native-note/start/new-project-and-run.md).

# New Project and Run

1.創建react native專案

開啟terminal，到你要的路徑下，使用react-native init learnProject(可以自行命名)

`$ react-native init learnProject`![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/new%20project%20and%20run%20on%20emulator/1.png)執行完成![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/new%20project%20and%20run%20on%20emulator/2.png)

\
2.執行ios請確保Xcode有更新到最新版本 terminal路徑為該專案內 在第一次執行專案前，必須先npm install安裝依賴包，如下

> ```
>  $ cd learnProject(此是你自己的專案名)
>  $ npm install 
>  $ react-native run-ios
> ```

![](https://703864731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGT_WSMJJJ-6nRhUva4%2F-LGTiO49T8vru3QICGtY%2F-LGTjZhH783yTOGmStiq%2F3.png?alt=media\&token=6ed9ef64-7162-497f-870b-6d83665d2708)

安裝好依賴包後，執行project，結果如下圖&#x20;

![](https://703864731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGT_WSMJJJ-6nRhUva4%2F-LGTiO49T8vru3QICGtY%2F-LGTjj52MNzFpMX7CgkI%2F4.png?alt=media\&token=27c03d59-c650-420f-9fdd-8eac3cc44a46)

\
3.執行android 請確保安裝的sdk有依照官方要求，並且注意android機器的版本，印象中是只支援5.0以上 要執行android前須先開啟模擬器或連接實體機器，但只能有一個裝置連接在debug模式上

```
$ android avd
$ adb devices
$ react-native run-android
```

* android avd，打開android studio內的Android Virtual Device Manager，執行模擬器 ![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/new%20project%20and%20run%20on%20emulator/5.png)
* 使用adb devices查看有連接在debug模式上的所有android裝置 ![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/new%20project%20and%20run%20on%20emulator/6.png)
* 執行project ![](https://bambooooo.gitbooks.io/react-native/content/React%20Native/images/new%20project%20and%20run%20on%20emulator/7.png)
