Skip to content

Commit c1cfa56

Browse files
authored
Merge pull request #117 from intercom/uv/add_setup_script
New setup script + updated readme
2 parents 588a3ad + 77d5e10 commit c1cfa56

File tree

2 files changed

+110
-18
lines changed

2 files changed

+110
-18
lines changed

example/README.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,46 @@
44

55
To get started with the @intercom/intercom-react-native example app, please follow the instructions below:
66

7-
1. Generate a new .env file by running the following command in your terminal:
8-
```sh
9-
sh scripts/generateEnv.sh
10-
```
11-
12-
This command will create a .env file inside the example directory.
7+
1. Install XCode before you setup the app.
8+
>Please note that there is a known bug that prevents the iOS app from building on the latest Xcode. Therefore, it's recommended to use Xcode 14.2.
139
14-
1. Fill in the required Android and iOS API keys and workspace IDs in the .env file. Other variables are optional.
1510

16-
2. Install the dependencies by running the following command in the project directory:
11+
2. Setup the app using:
12+
```sh
13+
./script/setup
14+
```
15+
This command will install all the dependencies required to run the example app.
1716

17+
3. Generate a new .env file by running the following command in your terminal:
1818
```sh
19-
yarn
19+
sh scripts/generateEnv.sh
2020
```
21+
This command will create a .env file <b>inside the example directory</b>.
22+
Fill in the required App ID in the .env file. Other variables are optional.
2123

22-
### Android
2324

24-
To run the app on Android, execute the following command:
2525

26+
## Running the app
27+
28+
To run the app on Android, execute the following command:
2629

2730
```sh
2831
yarn example android --variant=fossDebug
2932
```
3033

31-
### iOS
32-
For iOS, you need to install the necessary pods. Go to the example/ios directory in your terminal and run:
34+
To run the app on Android, execute the following command:
3335

3436
```sh
35-
pod install
37+
yarn example ios
3638
```
3739

38-
Once the pods are installed, go back to the project's root directory and execute the following command to run the app on iOS:
40+
## Troubleshooting
3941

42+
1. If you are facing issues related to pods, you can install them separately using:
4043
```sh
41-
yarn example ios
44+
pod install
4245
```
4346

44-
### Notes:
45-
Please note that there is a known bug that prevents the iOS app from building on the latest Xcode. Therefore, it's recommended to use Xcode 14.2.
47+
2. For issues related to android, try opening and running the example app from the android studio.
48+
49+
3. For general iOS build errors, opening and running the example app from XCode also helps.

script/setup

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/sh
2+
3+
#
4+
# Functions
5+
#
6+
function log() {
7+
echo "\n"
8+
echo "======================================="
9+
echo "$1"
10+
echo "======================================="
11+
}
12+
13+
14+
15+
EXPECTED_RUBY_VERSION=$(cat ${SOURCE_ROOT_DIR}/.ruby-version)
16+
ruby_version="2.4.4"
17+
rbenv_version="2.5.7"
18+
19+
log "🏎️ Running React native setup script 🏎️"
20+
21+
log "📱 Installing xcode tools 📱"
22+
23+
if [ ! -f /Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib ]; then
24+
echo "⚠️ Xcode CommandLineTools not found installing. Please install and rerun this script ⚠️"
25+
xcode-select --install
26+
exit 1
27+
fi
28+
echo "Xcode CommandLineTools installed 👍"
29+
30+
if ! [ -x "$(command -v xcode-select)" ]; then
31+
echo "⚠️ You need Xcode to setuo this project. Please install and rerun this script ⚠️"
32+
exit 1s
33+
fi
34+
35+
log "👀 Looking for Homebrew 👀"
36+
if ! [ -x "$(command -v brew)" ]; then
37+
echo "🍺 Installing Homebrew 🍺"
38+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
39+
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile
40+
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc
41+
else
42+
echo "Homebrew already installed 👍"
43+
fi
44+
45+
log "👀 Looking for rbenv 👀"
46+
47+
if ! [ -x "$(command -v rbenv)" ]; then
48+
echo "🍺 Installing rbenv with brew 🍺"
49+
brew install rbenv
50+
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
51+
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
52+
eval "$(rbenv init -)"
53+
rbenv install "2.5.7"
54+
else
55+
rbenv install "2.5.7"
56+
echo "rbenv already installed 👍"
57+
fi
58+
rbenv local "2.5.7"
59+
60+
log "👀 Looking for yarn 👀"
61+
if ! [ -x "$(command -v yarn)" ]; then
62+
echo "🍺 Installing yarn 🍺"
63+
brew install yarn
64+
else
65+
echo "yarn already installed 👍"
66+
fi
67+
68+
log "👀 Looking for ruby 👀"
69+
ruby-build --definitions | grep ^${EXPECTED_RUBY_VERSION} > /dev/null
70+
RUBYBUILD_DEFS_EXIT_CODE=$?
71+
if [ "$RUBYBUILD_DEFS_EXIT_CODE" -ne 0 ]; then
72+
echo "🍺 Ruby Build: Cannot find Ruby version required, updating via brew 🍺"
73+
brew update && brew upgrade ruby-build
74+
fi
75+
rbenv install --skip-existing
76+
echo "Ruby installed 👍"
77+
78+
log "📟 installing dependencies 📟"
79+
yarn
80+
81+
log "📟 installing dependencies for our example app 📟"
82+
cd example/ios
83+
pod install
84+
cd -
85+
86+
echo "You're all set up 👍"
87+
echo "📱 Run example app on iOS using -> yarn example ios"
88+
echo "📱 Run example app on android using -> yarn example android --variant=fossDebug"

0 commit comments

Comments
 (0)