The following instructions apply to both iOS and Android mobile apps. On macOS, we recommend using Homebrew as a package manager.
To install NVM using Homebrew, open a terminal and execute:
brew install nvm
To install Watchman using Homebrew, open a terminal and execute:
brew install watchman
npm -g install react-native-cli
A version of Ruby is automatically installed on macOS.
brew install git
Install Xcode to build and run the app on iOS. The minimum required version is 11.0.
- Follow the React Native environment setup docs until the cocoapods point, then stop.
- Specify the correct version of Xcode in the terminal: sudo xcode-select --switch /Applications/Xcode.app
- In the Rosetta terminal, change to the love-story/ios directory and run:
sudo arch -x86_64 gem install ffi
sudo gem install cocoapods
arch -x86_64 pod install
- If you need to use the Xcode app (e.g., to build, sign, and transfer the app to an iOS device), be sure to start it in Rosetta mode.
Download and install Android Studio or Android SDK CLI tools
Download and install the Android Studio app or the Android SDK command line tools
On Mac, this usually requires adding the following lines to your vim ~/.zshrc file:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH
Then reload your bash configuration:
source ~/.zshenv
Note: Depending on the shell you’re using, this might need to be put into a different file such as ~/.bash_profile. Adjust this accordingly.
In the SDK Manager using Android Studio or the Android SDK command line tool, ensure the following are installed:
-
Android SDK Build-Tools 31
-
Android Emulator
-
Android SDK Platform-Tools
-
Android SDK Tools
-
Google Play services
-
Intel x86 Emulator Accelerator (HAXM installer)
-
Support Repository
- Android Support Repository
- Google Repository
-
SDK Platforms (you may have to select Show Package Details to expand packages)
- Android 12 or above
- Google APIs
- SDK Platform
- Android SDK Platform 31 or above
- Intel or Google Play Intel x86 Atom_64 System Image
- Any other API version that you want to test
- Android 12 or above
- Fork the love-story repository on GitHub.
- Clone your fork locally:
- Open a terminal
- Change to a directory you want to hold your local copy
- Run git clone https://github.com/loyal-ki/love-story.git if you want to use HTTPS, or git clone [email protected]:loyal-ki/love-story.git if you want to use SSH
- Change the directory to love-story.
cd love-story
- Install the project dependencies with:
yarn all
We provide a set of scripts to help you run the app for the different platforms that are executed with npm/yarn:
- yarn start: Start the React Native packager. The packager has to be running in order to build the JavaScript code that powers the app.
- yarn android: Compile and run the mobile app on Android.
- yarn ios: Compile and run the mobile app on IOS.
To speed up development, only compile and run the apps in the following cases:
"adb": "adb reverse tcp:8081 tcp:8081",
"all": "watchman watch-del-all && rm -rf yarn.lock && rm -rf node_modules/ && rm -fr $TMPDIR/metro* && yarn install",
"android": "react-native run-android",
"eslint": "eslint --quiet --ext js,jsx,ts,tsx app --fix",
"fix": "prettier --write \"{app,src,modules}/**/*.{ts,tsx}\"",
"git-clean": "git config --local filter.turnOfDebugging.clean 'sed \"s/= true/= false/\"'",
"git-hide": "git update-index --skip-worktree packages/core/services/sender/getUrlForPath.ts",
"git-pull-rebase": "git config --local pull.rebase true",
"git-smudge": "git config --local filter.turnOfDebugging.smudge 'sed \"s/= true/= false/\"'",
"git-unhide": "git update-index --no-skip-worktree packages/core/services/sender/getUrlForPath.ts",
"ios": "react-native run-ios",
"ios-14": "react-native run-ios --simulator=\"iPhone 14 \"",
"ios-gems": "cd ios && bundle install",
"kill": "kill $(lsof -ti:8081)",
"lint": "tsc && eslint --quiet --ext js,jsx,ts,tsx app && jest",
"sort": "npx sort-package-json",
"start": "react-native start",
"test": "jest",
"test-no-cache": "jest --no-cache",
"visualize": "./node_modules/.bin/react-native-bundle-visualizer",
"postinstall": "patch-package"
By default, running the app will launch an Android emulator (if you created one) or an iOS simulator.
-
Enable debugging over USB
Most Android devices can only install and run apps downloaded from Google Play, by default. You will need to enable USB Debugging on your device in order to install your app during development.
To enable USB debugging on your device, you will first need to enable the "Developer options" menu by going to Settings → About phone → Software information and then tapping the Build number row at the bottom seven times. You can then go back to Settings → Developer options to enable "USB debugging".
-
Plug in your device via USB
To find the device name, run the following adb command:
$ adb devices
List of devices attached
abc1234 device
- Compile and run
yarn android
-
Connecting to the development server
Run the following in a command prompt:
$ adb -s <device name> reverse tcp:8081 tcp:8081
-
Get an Apple Developer account
The apps that run on an iOS device must be signed. To sign it, you’ll need a set of provisioning profiles. If you already have an Apple Developer account enrolled in the Apple Developer program you can skip this step. If you don’t have an account yet you’ll need to create one and enroll in the Apple Developer Program.
-
Open the project in Xcode
Navigate to the
ios
folder in your love_story project, then open the file love_story_typescript.xcworkspace in Xcode. -
Configure code signing and capabilities
Select the LoveStory project in the Xcode Project Navigator, then select the LoveStory target. Look for the Signing & Capabilities tab.
- Go to the Signing section and make sure your Apple developer account or team is selected under the Team dropdown and change the Bundle Identifier. Xcode will register your provisioning profiles in your account for the Bundle Identifier you’ve entered if it doesn’t exist.
- Go to the App Groups section and change the App Groups. Xcode will register your AppGroupId and update the provision profile.
- Go to the iCloud section and change the Containers. Xcode will register your iCloud container and update the provision profile.
- Go to the Keychain Sharing section and change the Keychain Groups. Xcode will register your Keychain access groups and update the provision profile.
-
Compile and run
Plug in your iOS device in any available USB port in your development computer.
If everything is set up correctly, your device will be listed as the build target in the Xcode toolbar, and it will also appear in the Devices Pane (⇧⌘2). You can press the Build and run button (⌘R) or select Run from the Product menu to run the app.
Note: If you run into any issues, please take a look at Apple’s Launching Your App on a Device documentation. If the app fails to build, go to the Product menu and select Clean Build Folder before trying to build the app again. Also, be sure that your iOS device is trusted so app deployments can proceed.