Skip to content

Commit 63f3077

Browse files
author
Eric Lange
authored
Update README.md
1 parent a83f64a commit 63f3077

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed

README.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,155 @@
11
# React Native Surface
22

33
A LiquidCore surface that exposes the React Native (v. 0.56) API. This is a work in progress.
4+
5+
## Create a React Native project for use with LiquidCore
6+
7+
Refer to the React Native documentation for how to get started with React Native. This assumes you are already familiar with it.
8+
9+
### Step 1: Create a React Native project
10+
11+
Important: you must use only version 0.56.0 of React Native. Create a new project from the command line:
12+
13+
```
14+
$ react-native init --version=0.56.0 HelloWorld
15+
```
16+
17+
### Step 2: Add the LiquidCore shim
18+
19+
First, install the command-line utilties:
20+
21+
```
22+
$ npm install -g liquidcore-cli
23+
```
24+
25+
Then, initialize your project for use with LiquidCore:
26+
27+
```
28+
$ liquidcore init --surface=.reactnative.ReactNative HelloWorld
29+
$ cd HelloWorld && npm install
30+
```
31+
32+
### Step 3: Complete
33+
34+
You should now have the basic React Native starter project that is available for use with LiquidCore. To run the development server, simply:
35+
36+
```
37+
$ npm run server
38+
```
39+
40+
Your project will remain entirely compatible with React Native. The LiquidCore dev server does not conflict with the Metro server. It uses port 8082 instead of 8081 by default. You can still debug and develop your React Native project according to the documentation without conflict. LiquidCore simply installs a little shim (namely, `liquid.js`) and enables a LiquidCore-specific server and bundler.
41+
42+
## Using ReactNativeSurface in your app
43+
44+
### Step 1: Create an app project
45+
46+
Create a new app in either Android Studio or XCode as normal. Or if you already have an existing app, you can use that. Refer to the documentation for your IDE on how to set up an app. For the sake of this section, we will assume you have an app named _HelloWorld_.
47+
48+
### Step 2: Add the dependencies
49+
50+
#### Android
51+
52+
Go to your **root-level `build.grade`** file and add the `jitpack` dependency:
53+
54+
```
55+
...
56+
57+
allprojects {
58+
repositories {
59+
jcenter()
60+
maven { url 'https://jitpack.io' }
61+
}
62+
}
63+
...
64+
```
65+
66+
Then, add the LiquidCore library to your **app's `build.gradle`**:
67+
68+
```
69+
dependencies {
70+
...
71+
implementation 'com.github.LiquidPlayer:LiquidCore:0.5.1'
72+
implementation 'com.github.LiquidPlayer:ReactNativeSurface:0.56.0001'
73+
}
74+
```
75+
76+
#### iOS
77+
78+
1. Install Carthage as described [here](https://github.com/Carthage/Carthage/blob/master/README.md#installing-carthage).
79+
2. Create a [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile) that includes the following frameworks:
80+
```
81+
git "git@github.com:LiquidPlayer/LiquidCore.git" ~> 0.5.1
82+
git "git@github.com:LiquidPlayer/ReactNativeSurface.git" ~> 0.56.0001
83+
```
84+
3. Run `carthage update`. This will fetch dependencies into a [Carthage/Checkouts](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#carthagecheckouts) folder, then build each one or download a pre-compiled framework.
85+
4. On your application targets’ _General_ settings tab, in the “Linked Frameworks and Libraries” section, drag and drop `LiquidCore.framework` and `ReactNativeSurface.framework` from the [Carthage/Build](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#carthagebuild) folder on disk.
86+
5. On your application targets’ _Build Phases_ settings tab, click the _+_ icon and choose _New Run Script Phase_. Create a Run Script in which you specify your shell (ex: `/bin/sh`), add the following contents to the script area below the shell:
87+
88+
```sh
89+
/usr/local/bin/carthage copy-frameworks
90+
```
91+
Then, add the paths to the frameworks under “Input Files":
92+
93+
```
94+
$(SRCROOT)/Carthage/Build/iOS/LiquidCore.framework
95+
$(SRCROOT)/Carthage/Build/iOS/ReactNativeSurface.framework
96+
```
97+
98+
And finally, add the paths to the copied frameworks to the “Output Files”:
99+
100+
```
101+
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/LiquidCore.framework
102+
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ReactNativeSurface.framework
103+
```
104+
105+
### Step 3: Add the Liquid View to your app
106+
107+
You can either add the view in the interface builder or programmatically. To add the view:
108+
109+
#### Android layout file
110+
111+
You can insert the view into any layout like so:
112+
113+
```xml
114+
<org.liquidplayer.service.LiquidView
115+
android:layout_width="match_parent"
116+
android:layout_height="match_parent"
117+
android:id="@+id/liquidview"
118+
/>
119+
```
120+
121+
#### iOS Interface Builder
122+
123+
Drag a `UIView` onto your storyboard in a `ViewController`. Go to the identity inspector on the right and
124+
set its custom class to `LCLiquidView`.
125+
126+
#### Android programmatic
127+
128+
```java
129+
import org.liquidplayer.service.LiquidView;
130+
...
131+
LiquidView liquidView = new LiquidView(androidContext);
132+
```
133+
134+
#### iOS (Swift)
135+
```swift
136+
import LiquidCore
137+
...
138+
let liquidView = LCLiquidView(frame: CGRect.zero)
139+
```
140+
141+
### Step 4: Finish
142+
143+
This is all that is required to get up and running. `LiquidView` defaults to using the dev server at port
144+
8082. See the documentation for `LiquidView` (Android) and `LCLiquidView` (iOS) in the [LiquidCore](https://github.com/LiquidPlayer/LiquidCore) project for options.
145+
146+
## Random Musings
147+
148+
This is very hastily thrown together documentation as this project is under active development. So I am adding some
149+
disorganized thoughts here.
150+
151+
* `ReactNativeSurface` is not yet suitable as a general-purpose surface. No (or very little) consideration has been made regarding security. Only use whitelisted domains or better yet, use local resource bundles until there has been more work in the area of security.
152+
* On Android, the back button doesn't always work like you want it to. This is a known issue.
153+
* Developer mode doesn't work on either Android or iOS. It doesn't work at all on Android and only somewhat works on iOS. For the moment, use old fashioned React Native to do your debugging until this is resolved.
154+
155+

0 commit comments

Comments
 (0)