Beginning with the Example Application
To start building our note taking application for iOS, we are going to need a couple
of command-line tools.
• React Native 0.14.2 requires Node.js v4+, we are going to use v5.0.0; visit
https://nodejs.org for more information (we recommend managing
different node versions with NVM https://github.com/creationix/nvm)
• Install the latest version of NPM from https://www.npmjs.com/
Great, now that we have these tools we can install the react-native-cli.
The react-native-cli exposes an interface that does all the work of setting
up a new React Native project for us:
1. To install react-native-cli, use the npm command:
npm install -g react-native-cli
2. Next, we are going to generate a new React Native project called ReactNotes
using the cli and the react-native init command. The output of the
command looks similar to the following:
$ react-native init ReactNotes
This will walk you through the creation of a new React Native project in
/Users/ethanholmes/ReactNotes.
3. Set up a new React Native app in /Users/ethanholmes/ReactNotes:
create .flowconfig
create .gitignore
create .watchmanconfig
create index.ios.js
create index.android.js
create ios/main.jsbundle
create ios/ReactNotes/AppDelegate.h
create ios/ReactNotes/AppDelegate.m
create ios/ReactNotes/Base.lproj/LaunchScreen.xib
create ios/ReactNotes/Images.xcassets/AppIcon.
appiconset/Contents json
create ios/ReactNotes/Info.plist
create ios/ReactNotes/main.m
create ios/ReactNotesTests/ReactNotesTests.m
create ios/ReactNotesTests/Info.plist
create ios/ReactNotes.xcodeproj/project.pbxproj
create ios/ReactNotes.xcodeproj/xcshareddata/xcschemes/
ReactNotes.xcscheme
create android/app/build.gradle
create android/app/proguard-rules.pro
create android/app/src/main/AndroidManifest.xml
create android/app/src/main/res/values/strings.xml
create android/app/src/main/res/values/styles.xml
create android/build.gradle
create android/gradle.properties
create android/settings.gradle
create android/app/src/main/res/mipmap-
hdpi/ic_launcher.png
create android/app/src/main/res/mipmap-
mdpi/ic_launcher.png
create android/app/src/main/res/mipmap-
xhdpi/ic_launcher.png
create android/app/src/main/res/mipmap-
xxhdpi/ic_launcher.png
create android/gradle/wrapper/gradle-wrapper.jar
create android/gradle/wrapper/gradle-wrapper.properties
create android/gradlew
create android/gradlew.bat
create android/app/src/main/java/com/reactnotes/
MainActivity.java
To run your app on iOS:
Open /Users/ethanholmes/ReactNotes/ios/ReactNotes.xcodeproj in
Xcode
Hit Run button
To run your app on Android:
Have an Android emulator running, or a device connected
cd /Users/ethanholmes/ReactNotes
react-native run-android
The root directory of the Xcode project is generated in the ReactNotes
folder, with the same name as we gave react-native-cli when we ran the
command. Follow the steps at the end of the React Native set up to see what
it produces.
of command-line tools.
• React Native 0.14.2 requires Node.js v4+, we are going to use v5.0.0; visit
https://nodejs.org for more information (we recommend managing
different node versions with NVM https://github.com/creationix/nvm)
• Install the latest version of NPM from https://www.npmjs.com/
Great, now that we have these tools we can install the react-native-cli.
The react-native-cli exposes an interface that does all the work of setting
up a new React Native project for us:
1. To install react-native-cli, use the npm command:
npm install -g react-native-cli
2. Next, we are going to generate a new React Native project called ReactNotes
using the cli and the react-native init command. The output of the
command looks similar to the following:
$ react-native init ReactNotes
This will walk you through the creation of a new React Native project in
/Users/ethanholmes/ReactNotes.
3. Set up a new React Native app in /Users/ethanholmes/ReactNotes:
create .flowconfig
create .gitignore
create .watchmanconfig
create index.ios.js
create index.android.js
create ios/main.jsbundle
create ios/ReactNotes/AppDelegate.h
create ios/ReactNotes/AppDelegate.m
create ios/ReactNotes/Base.lproj/LaunchScreen.xib
create ios/ReactNotes/Images.xcassets/AppIcon.
appiconset/Contents json
create ios/ReactNotes/Info.plist
create ios/ReactNotes/main.m
create ios/ReactNotesTests/ReactNotesTests.m
create ios/ReactNotesTests/Info.plist
create ios/ReactNotes.xcodeproj/project.pbxproj
create ios/ReactNotes.xcodeproj/xcshareddata/xcschemes/
ReactNotes.xcscheme
create android/app/build.gradle
create android/app/proguard-rules.pro
create android/app/src/main/AndroidManifest.xml
create android/app/src/main/res/values/strings.xml
create android/app/src/main/res/values/styles.xml
create android/build.gradle
create android/gradle.properties
create android/settings.gradle
create android/app/src/main/res/mipmap-
hdpi/ic_launcher.png
create android/app/src/main/res/mipmap-
mdpi/ic_launcher.png
create android/app/src/main/res/mipmap-
xhdpi/ic_launcher.png
create android/app/src/main/res/mipmap-
xxhdpi/ic_launcher.png
create android/gradle/wrapper/gradle-wrapper.jar
create android/gradle/wrapper/gradle-wrapper.properties
create android/gradlew
create android/gradlew.bat
create android/app/src/main/java/com/reactnotes/
MainActivity.java
To run your app on iOS:
Open /Users/ethanholmes/ReactNotes/ios/ReactNotes.xcodeproj in
Xcode
Hit Run button
To run your app on Android:
Have an Android emulator running, or a device connected
cd /Users/ethanholmes/ReactNotes
react-native run-android
The root directory of the Xcode project is generated in the ReactNotes
folder, with the same name as we gave react-native-cli when we ran the
command. Follow the steps at the end of the React Native set up to see what
it produces.
Comments
Post a Comment