xref: /expo/README.md (revision 191a2fb0)
1# Expo Client [![CircleCI](https://circleci.com/gh/expo/expo.svg?style=svg)](https://circleci.com/gh/expo/expo/tree/master) [![Forums](https://img.shields.io/badge/expo-forum-blue.svg)](https://forums.expo.io) [![Twitter: Expo](https://img.shields.io/twitter/follow/expo.svg?style=social)](https://twitter.com/expo) [![Twitter: expo_status](https://img.shields.io/twitter/follow/expo_status.svg?style=social)](https://twitter.com/expo_status)
2
3Expo is a set of tools, libraries, and services that let you build native iOS and Android apps by writing JavaScript. This repository is where the Expo client software is developed, and includes the client apps, modules, apps, and more.
4
5[Click here to view our documentation](https://docs.expo.io) for developing on Expo. If you're new to the Expo community, [click here to view the Expo Community Guidelines](https://expo.io/guidelines). Thank you for helping keep the Expo community open and welcoming!
6
7## Introduction
8
9This is the source code for the Expo client app used to view experiences published to the Expo service. If you want to build and install the Expo client directly onto a device, you're in the right place. Note that if you just want to install the Expo client app on a simulator, you do not need to build it from source. Instead, you should [follow the instructions here](https://docs.expo.io/versions/latest/introduction/installation.html).
10
11To build the Expo client app, follow the instructions in the [Set Up](#set-up) section below. Use the [expo-cli](https://docs.expo.io/versions/latest/workflow/expo-cli) command line to use Expo's infrastructure to build your app.
12
13Please ask us on the [forums](https://forums.expo.io/) if you get stuck.
14
15**Disclaimers:**
16
17If you want to build a standalone app that has a custom icon and name, see [our documentation here](https://docs.expo.io/versions/latest/distribution/building-standalone-apps/). You're in the wrong place, you shouldn't need to build the Expo clients from source.
18
19If you need to make native code changes to your Expo project, such as adding custom native modules, we can [generate a native project for you](https://docs.expo.io/versions/latest/expokit/eject). You're in the wrong place, you shouldn't need to build the Expo clients from source.
20
21## Set Up
22
23Note: We support building the clients only on macOS.
24
25- Install [nix](https://nixos.org/nix) (currently `curl https://nixos.org/nix/install | sh`)
26- Install [direnv](http://direnv.net/) (to do this with nix, run `nix-env -iA nixpkgs.direnv`)
27- Clone this repo; we recommend cloning it to a directory whose full path does not include any spaces (you should clone all the submodules with `git clone --recurse-submodules`)
28- Run `yarn` in the root and `tools-public` directories.
29- Run `yarn build` in the `packages/expo` directory.
30
31#### iOS
32
33- Make sure you have latest non-beta Xcode installed.
34- Run `git lfs pull`.
35- Run `et ios-generate-dynamic-macros`.
36- Open and run `ios/Exponent.xcworkspace` in Xcode.
37
38#### Android
39
40- Make sure you have Android Studio 3 installed
41- Run `android/install-ndk-17c.sh` to get the required version of the Android NDK.
42- See "Running on a Device"
43
44## Running on a Device
45
46### iOS
47
48- In Xcode's menu bar, open the **Xcode** drop-down menu, and select **Preferences**. Then in the **Accounts** tab of the preferences menu, add your personal or team apple developer account.
49- Connect your test device to your computer with a USB cable.
50- In Xcode's menu bar, open the **Product** drop-down menu, select **Destination**, then in the _Device_ grouping select your device.
51- In the project navigator, select the **Exponent** project to bring up the project's settings, and then:
52  - In the **General** tab, in the **Identity** section, put in a unique Bundle Identifier.
53  - Also in the **General** tab, in the **Signing** section, select your personal or team apple developer account as your **Team**, and create a new signing certificate by clicking **Fix Issue**.
54- Finally, run the build
55
56### Android
57
58- If the Play Store version of the Expo Client App is installed on your test device, uninstall it.
59- Connect your test device to your computer with a USB cable.
60- Run `fastlane android start`, or alternately open the `android` directory in Android Studio, start it, and in the **Select Deployment Target** dialog, select your device.
61
62## Standalone Apps
63
64If you don't need custom native code outside of the Expo SDK, head over to [our documentation on building standalone apps without needing Android Studio and Xcode](https://docs.expo.io/versions/latest/distribution/building-standalone-apps/).
65
66If you need standalone apps as built by running `expo build:ios` or `expo build:android` for a supported SDK version, check out our docs on [using turtle-cli to build apps locally or on CI](https://docs.expo.io/versions/latest/distribution/turtle-cli/).
67
68If you're still here, you need to build a standalone app with code currently on `master` or another unreleased branch. Make sure to follow the [Configure app.json](https://docs.expo.io/versions/latest/distribution/building-standalone-apps/#2-configure-appjson) section of the docs before continuing. You'll need to add the appropriate fields to your `app.json` before the standalone app scripts can run. Once that's done, continue on to the platform-specific instructions.
69
70#### Android
71
72The Android standalone app script creates a new directory `android-shell-app` with the modified Android project in it. It then compiles that new directory giving you a signed or unsigned `.apk` depending on whether you provide a keystore and the necessary passwords. If there are issues with the app you can open the `android-shell-app` project in Android Studio to debug.
73
74Here are the steps to build a standalone Android app:
75
76- Publish your experience with Expo CLI. Note the published URL.
77- If you want a signed `.apk`, run `et android-shell-app --url [the published experience url] --sdkVersion [sdk version of your experience] --keystore [path to keystore] --alias [keystore alias] --keystorePassword [keystore password] --keyPassword [key password]`.
78- If you don't want a signed `.apk`, run `et android-shell-app --url [the published experience url] --sdkVersion [sdk version of your experience]`.
79- The `.apk` file will be at `/tmp/shell-signed.apk` for a signed `.apk` or at `/tmp/shell-debug.apk` for an unsigned `.apk`.
80
81#### iOS
82
83The iOS standalone app script has two actions, `build` and `configure`. `build` creates an archive or a simulator build of the Expo iOS workspace. `configure` accepts a path to an existing archive and modifies all its configuration files so that it will run as a standalone Expo experience rather than as the Expo client app.
84
85Here are the steps to build a standalone iOS app:
86
87- Publish your experience with Expo CLI. Note the published URL.
88- `cd tools-public`.
89- `gulp ios-shell-app --action build --type [simulator or archive] --configuration [Debug or Release]`
90- The resulting archive will be created at `../shellAppBase-[type]`.
91- `gulp ios-shell-app --url [the published experience url] --action configure --type [simulator or archive] --archivePath [path to ExpoKitApp.app] --sdkVersion [sdk version of your experience] --output your-app.tar.gz`
92- This bundle is not signed and cannot be submitted to iTunes Connect as-is; you'll need to manually sign it if you'd like to submit it to Apple. [Fastlane](https://fastlane.tools/) is a good option for this. Also, [Expo will do this for you](https://docs.expo.io/versions/latest/distribution/building-standalone-apps/) if you don't need to build this project from source.
93- If you created a simulator build in the first step, unpack the tar.gz using `tar -xvzf your-app.tar.gz`. Then you can run this on iPhone Simulator using `xcrun simctl install booted <app path>` and `xcrun simctl launch booted <app identifier>`. Another alternative which some people prefer is to install the [ios-sim](https://github.com/phonegap/ios-sim) tool and then use `ios-sim launch <app path>`.
94- There are a few more optional flags you can pass to this script. They are all documented in the block comments inside `xdl/src/detach/IosShellApp.js`.
95
96## Modifying JS Code
97
98The Expo client apps run a root Expo project in addition to native code. By default this will use a published version of the project, so any changes made in the `home` directory will not show up without some extra work.
99
100Serve this project locally by running `expo start` from the `home` directory. On iOS, you'll additionally need to set `DEV_KERNEL_SOURCE` to `LOCAL` in `EXBuildConstants.plist` (the default is `PUBLISHED`).
101
102The native Android Studio and XCode projects have a build hook which will find this if `expo start` is running. Keep this running and rebuild the app on each platform.
103
104## Project Layout
105
106- `android` contains the Android project.
107- `home` contains the JavaScript source code of the app.
108- `ios` contains the iOS project.
109- `ios/Exponent.xcworkspace` is the Xcode workspace. Always open this instead of `Exponent.xcodeproj` because the workspace also loads the CocoaPods dependencies.
110- `tools-public` contains build and configuration tools.
111- `template-files` contains templates for files that require private keys. They are populated using the keys in `template-files/keys.json`.
112- `template-files/ios/dependencies.json` specifies the CocoaPods dependencies of the app.
113
114## Tests
115
116### iOS
117
118For native XCTest unit tests:
119
120- Press Command+U in XCode to build and test the `Tests` unit test target.
121- Alternatively, run `fastlane ios test` from the parent directory of `ios`.
122
123For JS integration tests, test the `ExponentIntegrationTests` target (not included in the default test scheme). This target requires you to configure `EXTestEnvironment.plist` with a key `testSuiteUrl` whose value is the URL to load some version of Expo's [test-suite](apps/test-suite) app. This will run a bunch of Jasmine tests against the Expo SDK.
124
125## Contributing
126
127### Foundation Unimodules
128
129The Foundation Unimodules by Expo are under `packages`, along with other JS packages. Each Unimodule has its own tests in its package (`yarn test`) and under `apps/test-suite` (run a development build of the Expo client, run `expo start` in `test-suite`, and load it on a device). We recommend reading the source for several Unimodules to get a sense of the code conventions and taste.
130
131- [Guide to Unimodule Development](guides/Expo%20Universal%20Module%20Infrastructure.md)
132- [Contributing to Expo in General](CONTRIBUTING.md)
133- [Expo JS Style Guide](guides/Expo%20JavaScript%20Style%20Guide.md) (also mostly applies to TypeScript)
134
135### Expo client
136
137Please check with us before putting work into a Pull Request! We don't yet have a good guide available that covers the nuances of how to work with the Expo client so you will want a direct line of communication with someone on the team to ask us questions. The best place to talk to us is either on Slack at https://slack.expo.io or the forums at https://forums.expo.io.
138
139## License
140
141The Expo source code is made available under the [MIT license](LICENSE). Some of the dependencies are licensed differently, with the BSD license, for example.
142