Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 19f2bb4

Browse files
authored
Merge pull request #1259 from lightninglabs/mobile/bare-react-native-replace-expo
Mobile/bare react native replace expo
2 parents 11fae4d + ac516f3 commit 19f2bb4

File tree

97 files changed

+4023
-3235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4023
-3235
lines changed

mobile/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["module:metro-react-native-babel-preset"]
3+
}

mobile/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

mobile/.expo-shared/assets.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

mobile/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

mobile/.gitignore

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1-
# See https://help.github.com/ignore-files/ for more about ignoring files.
2-
3-
# expo
4-
.expo/*
5-
6-
# dependencies
7-
node_modules/**/*
8-
ios/Pods/**/*
9-
10-
# misc
11-
.env.local
12-
.env.development.local
13-
.env.test.local
14-
.env.production.local
15-
16-
npm-debug.*
17-
yarn-debug.log*
18-
yarn-error.log*
19-
*.jks
20-
*.p12
21-
*.key
22-
*.mobileprovision
1+
# OSX
2+
#
3+
.DS_Store
234

245
# Xcode
6+
#
257
build/
268
*.pbxuser
279
!default.pbxuser
@@ -38,18 +20,43 @@ DerivedData
3820
*.hmap
3921
*.ipa
4022
*.xcuserstate
41-
ios/lightning.xcworkspace/xcshareddata
23+
project.xcworkspace
24+
ios/Pods
25+
ios/lightningApp.xcworkspace/xcshareddata
4226
ios/lightning/Lndmobile.framework
4327
ios/lightning/Supporting/EXShell.json
4428
ios/lightning/Supporting/EXShell.plist.bak
4529

46-
# Android/IJ
30+
# Android/IntelliJ
31+
#
32+
build/
4733
.idea
4834
.gradle
4935
local.properties
50-
*.aab
51-
*.apk
5236
android/Lndmobile/Lndmobile.aar
53-
android/app/src/main/assets/shell-app.bundle
54-
android/app/src/main/assets/shell-app-manifest.json
55-
android/app/prodKernel/
37+
android/app/release/
38+
39+
# node.js
40+
#
41+
node_modules/
42+
npm-debug.log
43+
yarn-error.log
44+
45+
# BUCK
46+
buck-out/
47+
\.buckd/
48+
*.keystore
49+
50+
# fastlane
51+
#
52+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
53+
# screenshots whenever they are needed.
54+
# For more information about the recommended setup visit:
55+
# https://docs.fastlane.tools/best-practices/source-control/
56+
57+
*/fastlane/report.xml
58+
*/fastlane/Preview.html
59+
*/fastlane/screenshots
60+
61+
# Bundle artifact
62+
*.jsbundle

mobile/.watchmanconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

mobile/App.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import 'node-libs-react-native/globals';
2-
import { Platform } from 'react-native';
32

43
// Polyfill ECMAScript Internationalization API on Android
54
// See: https://github.com/facebook/react-native/issues/19410
6-
if (Platform.OS === 'android') {
7-
require('intl');
8-
require('intl/locale-data/jsonp/en-US');
9-
}
5+
import 'intl';
6+
import 'intl/locale-data/jsonp/en-US';
7+
8+
import { StyleSheet } from 'react-native';
9+
import * as Font from 'expo-font';
10+
StyleSheet.setStyleAttributePreprocessor('fontFamily', Font.processFontFamily);
1011

1112
import App from '../src/view/main-mobile';
1213

mobile/README.md

Lines changed: 52 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -1,218 +1,83 @@
1-
This project was bootstrapped with [Create React Native App](https://github.com/react-community/create-react-native-app).
1+
Lightning mobile app
2+
==========
23

3-
Below you'll find information about performing common tasks. The most recent version of this guide is available [here](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md).
4+
## Getting started
45

5-
## Table of Contents
6+
This project was bootstrapped using [Expo CLI as a bare project](https://blog.expo.io/you-can-now-use-expo-apis-in-any-react-native-app-7c3a93041331). You should only need `react-native-cli` for development not `expo-cli`. See the [React Native CLI Getting Started Guide](https://facebook.github.io/react-native/docs/getting-started.html)
67

7-
* [Updating to New Releases](#updating-to-new-releases)
8-
* [Available Scripts](#available-scripts)
9-
* [npm start](#npm-start)
10-
* [npm test](#npm-test)
11-
* [npm run ios](#npm-run-ios)
12-
* [npm run android](#npm-run-android)
13-
* [npm run eject](#npm-run-eject)
14-
* [Writing and Running Tests](#writing-and-running-tests)
15-
* [Environment Variables](#environment-variables)
16-
* [Configuring Packager IP Address](#configuring-packager-ip-address)
17-
* [Customizing App Display Name and Icon](#customizing-app-display-name-and-icon)
18-
* [Sharing and Deployment](#sharing-and-deployment)
19-
* [Publishing to Expo's React Native Community](#publishing-to-expos-react-native-community)
20-
* [Building an Expo "standalone" app](#building-an-expo-standalone-app)
21-
* [Ejecting from Create React Native App](#ejecting-from-create-react-native-app)
22-
* [Build Dependencies (Xcode & Android Studio)](#build-dependencies-xcode-android-studio)
23-
* [Should I Use ExpoKit?](#should-i-use-expokit)
24-
* [Troubleshooting](#troubleshooting)
25-
* [Networking](#networking)
26-
* [iOS Simulator won't open](#ios-simulator-wont-open)
27-
* [QR Code does not scan](#qr-code-does-not-scan)
8+
## Building lnd
289

29-
## Updating to New Releases
10+
### Build dependencies
3011

31-
You should only need to update the global installation of `create-react-native-app` very rarely, ideally never.
12+
* node 10 LTS (brew install node@10)
13+
* react-native-cli (npm install -g react-native-cli)
14+
* watchman (brew install watchman)
15+
* Xcode
16+
* cocoapods 1.7.2 (brew install cocoapods)
17+
* go 1.11.6 (brew install go@1.11)
18+
* [gomobile](https://github.com/golang/go/wiki/Mobile)
19+
* [lnd mobile build tools](https://github.com/lightninglabs/lnd/tree/mobile-autopilot-100)
20+
* [Java](https://www.oracle.com/technetwork/java/javase/downloads/index.html)
21+
* [Android Studio](https://developer.android.com/studio)
22+
* [Android NDK](https://developer.android.com/ndk/guides)
3223

33-
Updating the `react-native-scripts` dependency of your app should be as simple as bumping the version number in `package.json` and reinstalling your project's dependencies.
24+
### Building
3425

35-
Upgrading to a new version of React Native requires updating the `react-native`, `react`, and `expo` package versions, and setting the correct `sdkVersion` in `app.json`. See the [versioning guide](https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md) for up-to-date information about package version compatibility.
36-
37-
## Available Scripts
38-
39-
If Yarn was installed when the project was initialized, then dependencies will have been installed via Yarn, and you should probably use it to run these commands as well. Unlike dependency installation, command running syntax is identical for Yarn and NPM at the time of this writing.
40-
41-
### `npm start`
42-
43-
Runs your app in development mode.
44-
45-
Open it in the [Expo app](https://expo.io) on your phone to view it. It will reload if you save edits to your files, and you will see build errors and logs in the terminal.
46-
47-
Sometimes you may need to reset or clear the React Native packager's cache. To do so, you can pass the `--reset-cache` flag to the start script:
48-
49-
```
50-
npm start --reset-cache
51-
# or
52-
yarn start --reset-cache
53-
```
54-
55-
#### `npm test`
56-
57-
Runs the [jest](https://github.com/facebook/jest) test runner on your tests.
58-
59-
#### `npm run ios`
60-
61-
Like `npm start`, but also attempts to open your app in the iOS Simulator if you're on a Mac and have it installed.
62-
63-
#### `npm run android`
64-
65-
Like `npm start`, but also attempts to open your app on a connected Android device or emulator. Requires an installation of Android build tools (see [React Native docs](https://facebook.github.io/react-native/docs/getting-started.html) for detailed setup). We also recommend installing Genymotion as your Android emulator. Once you've finished setting up the native build environment, there are two options for making the right copy of `adb` available to Create React Native App:
66-
67-
##### Using Android Studio's `adb`
68-
69-
1. Make sure that you can run adb from your terminal.
70-
2. Open Genymotion and navigate to `Settings -> ADB`. Select “Use custom Android SDK tools” and update with your [Android SDK directory](https://stackoverflow.com/questions/25176594/android-sdk-location).
71-
72-
##### Using Genymotion's `adb`
73-
74-
1. Find Genymotion’s copy of adb. On macOS for example, this is normally `/Applications/Genymotion.app/Contents/MacOS/tools/`.
75-
2. Add the Genymotion tools directory to your path (instructions for [Mac](http://osxdaily.com/2014/08/14/add-new-path-to-path-command-line/), [Linux](http://www.computerhope.com/issues/ch001647.htm), and [Windows](https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/)).
76-
3. Make sure that you can run adb from your terminal.
77-
78-
#### `npm run eject`
79-
80-
This will start the process of "ejecting" from Create React Native App's build scripts. You'll be asked a couple of questions about how you'd like to build your project.
81-
82-
**Warning:** Running eject is a permanent action (aside from whatever version control system you use). An ejected app will require you to have an [Xcode and/or Android Studio environment](https://facebook.github.io/react-native/docs/getting-started.html) set up.
83-
84-
## Customizing App Display Name and Icon
85-
86-
You can edit `app.json` to include [configuration keys](https://docs.expo.io/versions/latest/guides/configuration.html) under the `expo` key.
87-
88-
To change your app's display name, set the `expo.name` key in `app.json` to an appropriate string.
89-
90-
To set an app icon, set the `expo.icon` key in `app.json` to be either a local path or a URL. It's recommended that you use a 512x512 png file with transparency.
91-
92-
## Writing and Running Tests
93-
94-
This project is set up to use [jest](https://facebook.github.io/jest/) for tests. You can configure whatever testing strategy you like, but jest works out of the box. Create test files in directories called `__tests__` or with the `.test` extension to have the files loaded by jest. See the [the template project](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/App.test.js) for an example test. The [jest documentation](https://facebook.github.io/jest/docs/en/getting-started.html) is also a wonderful resource, as is the [React Native testing tutorial](https://facebook.github.io/jest/docs/en/tutorial-react-native.html).
95-
96-
## Environment Variables
97-
98-
You can configure some of Create React Native App's behavior using environment variables.
99-
100-
### Configuring Packager IP Address
101-
102-
When starting your project, you'll see something like this for your project URL:
103-
104-
```
105-
exp://192.168.0.2:19000
10626
```
107-
108-
The "manifest" at that URL tells the Expo app how to retrieve and load your app's JavaScript bundle, so even if you load it in the app via a URL like `exp://localhost:19000`, the Expo client app will still try to retrieve your app at the IP address that the start script provides.
109-
110-
In some cases, this is less than ideal. This might be the case if you need to run your project inside of a virtual machine and you have to access the packager via a different IP address than the one which prints by default. In order to override the IP address or hostname that is detected by Create React Native App, you can specify your own hostname via the `REACT_NATIVE_PACKAGER_HOSTNAME` environment variable:
111-
112-
Mac and Linux:
113-
114-
```
115-
REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start
116-
```
117-
118-
Windows:
119-
```
120-
set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname'
121-
npm start
27+
go get golang.org/x/mobile/cmd/gomobile
28+
cd lnd
29+
make clean
30+
gomobile init
31+
make mobile
12232
```
12333

124-
The above example would cause the development server to listen on `exp://my-custom-ip-address-or-hostname:19000`.
34+
Next copy the lnd mobile binaries to this project
12535

126-
## Sharing and Deployment
36+
1. `lnd/mobile/build/ios/Lndmobile.framework` -> `ios/lightning`
37+
2. `lnd/mobile/build/android/Lndmobile.aar` -> `android/Lndmobile`
12738

128-
Create React Native App does a lot of work to make app setup and development simple and straightforward, but it's very difficult to do the same for deploying to Apple's App Store or Google's Play Store without relying on a hosted service.
39+
## Running the app
12940

130-
### Publishing to Expo's React Native Community
131-
132-
Expo provides free hosting for the JS-only apps created by CRNA, allowing you to share your app through the Expo client app. This requires registration for an Expo account.
133-
134-
Install the `exp` command-line tool, and run the publish command:
41+
### Install the dependencies
13542

13643
```
137-
$ npm i -g exp
138-
$ exp publish
44+
npm install (first in git `/` and then in `/mobile`)
45+
cd ios
46+
pod install
47+
cd ..
13948
```
14049

141-
### Building an Expo "standalone" app
142-
143-
You can also use a service like [Expo's standalone builds](https://docs.expo.io/versions/latest/guides/building-standalone-apps.html) if you want to get an IPA/APK for distribution without having to build the native code yourself.
144-
145-
### Ejecting from Create React Native App
146-
147-
If you want to build and deploy your app yourself, you'll need to eject from CRNA and use Xcode and Android Studio.
148-
149-
This is usually as simple as running `npm run eject` in your project, which will walk you through the process. Make sure to install `react-native-cli` and follow the [native code getting started guide for React Native](https://facebook.github.io/react-native/docs/getting-started.html).
150-
151-
#### Should I Use ExpoKit?
152-
153-
If you have made use of Expo APIs while working on your project, then those API calls will stop working if you eject to a regular React Native project. If you want to continue using those APIs, you can eject to "React Native + ExpoKit" which will still allow you to build your own native code and continue using the Expo APIs. See the [ejecting guide](https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md) for more details about this option.
154-
155-
## Troubleshooting
156-
157-
### Networking
158-
159-
If you're unable to load your app on your phone due to a network timeout or a refused connection, a good first step is to verify that your phone and computer are on the same network and that they can reach each other. Create React Native App needs access to ports 19000 and 19001 so ensure that your network and firewall settings allow access from your device to your computer on both of these ports.
160-
161-
Try opening a web browser on your phone and opening the URL that the packager script prints, replacing `exp://` with `http://`. So, for example, if underneath the QR code in your terminal you see:
50+
### Start the app in the simulator
16251

16352
```
164-
exp://192.168.0.1:19000
53+
npm run ios
54+
npm run android
16555
```
16656

167-
Try opening Safari or Chrome on your phone and loading
57+
### Debugging the app in Xcode or Android Studio
16858

169-
```
170-
http://192.168.0.1:19000
171-
```
172-
173-
and
59+
Start the metro development server
17460

17561
```
176-
http://192.168.0.1:19001
62+
npm start
17763
```
17864

179-
If this works, but you're still unable to load your app by scanning the QR code, please open an issue on the [Create React Native App repository](https://github.com/react-community/create-react-native-app) with details about these steps and any other error messages you may have received.
180-
181-
If you're not able to load the `http` URL in your phone's web browser, try using the tethering/mobile hotspot feature on your phone (beware of data usage, though), connecting your computer to that WiFi network, and restarting the packager. If you are using a VPN you may need to disable it.
182-
183-
### iOS Simulator won't open
184-
185-
If you're on a Mac, there are a few errors that users sometimes see when attempting to `npm run ios`:
186-
187-
* "non-zero exit code: 107"
188-
* "You may need to install Xcode" but it is already installed
189-
* and others
190-
191-
There are a few steps you may want to take to troubleshoot these kinds of errors:
192-
193-
1. Make sure Xcode is installed and open it to accept the license agreement if it prompts you. You can install it from the Mac App Store.
194-
2. Open Xcode's Preferences, the Locations tab, and make sure that the `Command Line Tools` menu option is set to something. Sometimes when the CLI tools are first installed by Homebrew this option is left blank, which can prevent Apple utilities from finding the simulator. Make sure to re-run `npm/yarn run ios` after doing so.
195-
3. If that doesn't work, open the Simulator, and under the app menu select `Reset Contents and Settings...`. After that has finished, quit the Simulator, and re-run `npm/yarn run ios`.
196-
197-
### QR Code does not scan
198-
199-
If you're not able to scan the QR code, make sure your phone's camera is focusing correctly, and also make sure that the contrast on the two colors in your terminal is high enough. For example, WebStorm's default themes may [not have enough contrast](https://github.com/react-community/create-react-native-app/issues/49) for terminal QR codes to be scannable with the system barcode scanners that the Expo app uses.
200-
201-
If this causes problems for you, you may want to try changing your terminal's color theme to have more contrast, or running Create React Native App from a different terminal. You can also manually enter the URL printed by the packager script in the Expo app's search bar to load it manually.
65+
Then just open `ios/LightningApp.xcworkspace` from the finder on your mac. Or open the project in the `android` directory in Android Studio.
20266

203-
# Building lnd
67+
## Releasing
20468

205-
## Build dependencies
69+
### iOS
20670

207-
* node 10 LTS
208-
* expo-cli (npm install -g expo-cli)
209-
* cocoapods 1.5.3
210-
* go 1.11.6
71+
1. Open `ios/LightningApp.xcworkspace` from the finder on your mac
72+
2. From xcode set the active scheme to `Release`
73+
3. Set the build target as `Generic iOS device`
74+
4. Bump the version and build number in the project
75+
5. Build the Archive in the menu under `Product -> Archive`
21176

212-
https://github.com/golang/go/wiki/Mobile
213-
https://github.com/lightninglabs/lnd/tree/mobile-build-tool
214-
`make mobile` is the golden command
77+
### Android
21578

216-
ideally this should be the only setup you would need:
217-
`go get golang.org/x/mobile/cmd/gomobile`
218-
`gomobile init # it might take a few minutes`
79+
1. Open Android Studio
80+
2. open the project in the `android` directory
81+
3. Bump the `versionName` and `versionCode` under `app/build.gradle`
82+
4. From the menu `Build -> Clean Project`
83+
5. From the menu `Build -> Generate Signed Bundle / APK`

0 commit comments

Comments
 (0)