Skip to content

Commit 9b40c59

Browse files
committed
updated template to match latest version
1 parent 51b9a2e commit 9b40c59

File tree

10 files changed

+98
-66
lines changed

10 files changed

+98
-66
lines changed

template/App.tsx

100644100755
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Sample React Native App
33
* https://github.com/facebook/react-native
4-
*
4+
*
55
* Generated with the TypeScript template
66
* https://github.com/emin93/react-native-template-typescript
77
*
@@ -35,6 +35,11 @@ const App = () => {
3535
contentInsetAdjustmentBehavior="automatic"
3636
style={styles.scrollView}>
3737
<Header />
38+
{global.HermesInternal == null ? null : (
39+
<View style={styles.engine}>
40+
<Text style={styles.footer}>Engine: Hermes</Text>
41+
</View>
42+
)}
3843
<View style={styles.body}>
3944
<View style={styles.sectionContainer}>
4045
<Text style={styles.sectionTitle}>Step One</Text>
@@ -73,6 +78,10 @@ const styles = StyleSheet.create({
7378
scrollView: {
7479
backgroundColor: Colors.lighter,
7580
},
81+
engine: {
82+
position: 'absolute',
83+
right: 0,
84+
},
7685
body: {
7786
backgroundColor: Colors.white,
7887
},
@@ -94,6 +103,14 @@ const styles = StyleSheet.create({
94103
highlight: {
95104
fontWeight: '700',
96105
},
106+
footer: {
107+
color: Colors.dark,
108+
fontSize: 12,
109+
fontWeight: '600',
110+
padding: 4,
111+
paddingRight: 12,
112+
textAlign: 'right',
113+
},
97114
});
98115

99116
export default App;

template/__tests__/App-test.tsx

100644100755
File mode changed.

template/_gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
xcshareddata
23+
project.xcworkspace
2424

2525
# Android/IntelliJ
2626
#

template/android/app/build.gradle

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ import com.android.build.OutputFile
7676
*/
7777

7878
project.ext.react = [
79-
entryFile: "index.js"
79+
entryFile: "index.js",
80+
enableHermes: false, // clean and rebuild if changing
8081
]
8182

8283
apply from: "../../node_modules/react-native/react.gradle"
@@ -97,13 +98,26 @@ def enableSeparateBuildPerCPUArchitecture = false
9798
def enableProguardInReleaseBuilds = false
9899

99100
/**
100-
* Use international variant JavaScriptCore
101-
* International variant includes ICU i18n library and necessary data allowing to use
102-
* e.g. Date.toLocaleString and String.localeCompare that give correct results
103-
* when using with locales other than en-US.
104-
* Note that this variant is about 6MiB larger per architecture than default.
101+
* The preferred build flavor of JavaScriptCore.
102+
*
103+
* For example, to use the international variant, you can use:
104+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105+
*
106+
* The international variant includes ICU i18n library and necessary data
107+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108+
* give correct results when using with locales other than en-US. Note that
109+
* this variant is about 6MiB larger per architecture than default.
105110
*/
106-
def useIntlJsc = false
111+
def jscFlavor = 'org.webkit:android-jsc:+'
112+
113+
/**
114+
* Whether to enable the Hermes VM.
115+
*
116+
* This should be set on project.ext.react and mirrored here. If it is not set
117+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118+
* and the benefits of using Hermes will therefore be sharply reduced.
119+
*/
120+
def enableHermes = project.ext.react.get("enableHermes", false);
107121

108122
android {
109123
compileSdkVersion rootProject.ext.compileSdkVersion
@@ -159,19 +173,30 @@ android {
159173
output.versionCodeOverride =
160174
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
161175
}
176+
162177
}
163178
}
179+
180+
packagingOptions {
181+
pickFirst '**/armeabi-v7a/libc++_shared.so'
182+
pickFirst '**/x86/libc++_shared.so'
183+
pickFirst '**/arm64-v8a/libc++_shared.so'
184+
pickFirst '**/x86_64/libc++_shared.so'
185+
pickFirst '**/x86/libjsc.so'
186+
pickFirst '**/armeabi-v7a/libjsc.so'
187+
}
164188
}
165189

166190
dependencies {
167191
implementation fileTree(dir: "libs", include: ["*.jar"])
168192
implementation "com.facebook.react:react-native:+" // From node_modules
169193

170-
// JSC from node_modules
171-
if (useIntlJsc) {
172-
implementation 'org.webkit:android-jsc-intl:+'
194+
if (enableHermes) {
195+
def hermesPath = "../../node_modules/hermesvm/android/";
196+
debugImplementation files(hermesPath + "hermes-debug.aar")
197+
releaseImplementation files(hermesPath + "hermes-release.aar")
173198
} else {
174-
implementation 'org.webkit:android-jsc:+'
199+
implementation jscFlavor
175200
}
176201
}
177202

template/android/app/src/main/java/com/helloworld/MainActivity.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
public class MainActivity extends ReactActivity {
66

7-
/**
8-
* Returns the name of the main component registered from JavaScript. This is used to schedule
9-
* rendering of the component.
10-
*/
11-
@Override
12-
protected String getMainComponentName() {
13-
return "HelloWorld";
14-
}
7+
/**
8+
* Returns the name of the main component registered from JavaScript.
9+
* This is used to schedule rendering of the component.
10+
*/
11+
@Override
12+
protected String getMainComponentName() {
13+
return "HelloWorld";
14+
}
1515
}

template/android/app/src/main/java/com/helloworld/MainApplication.java

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
package com.helloworld;
22

33
import android.app.Application;
4+
import android.util.Log;
5+
46
import com.facebook.react.PackageList;
7+
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
8+
import com.facebook.react.bridge.JavaScriptExecutorFactory;
59
import com.facebook.react.ReactApplication;
610
import com.facebook.react.ReactNativeHost;
711
import com.facebook.react.ReactPackage;
812
import com.facebook.soloader.SoLoader;
13+
914
import java.util.List;
1015

1116
public class MainApplication extends Application implements ReactApplication {
1217

13-
private final ReactNativeHost mReactNativeHost =
14-
new ReactNativeHost(this) {
15-
@Override
16-
public boolean getUseDeveloperSupport() {
17-
return BuildConfig.DEBUG;
18-
}
19-
20-
@Override
21-
protected List<ReactPackage> getPackages() {
22-
@SuppressWarnings("UnnecessaryLocalVariable")
23-
List<ReactPackage> packages = new PackageList(this).getPackages();
24-
// Packages that cannot be autolinked yet can be added manually here, for example:
25-
// packages.add(new MyReactNativePackage());
26-
return packages;
27-
}
28-
29-
@Override
30-
protected String getJSMainModuleName() {
31-
return "index";
32-
}
33-
};
18+
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
19+
@Override
20+
public boolean getUseDeveloperSupport() {
21+
return BuildConfig.DEBUG;
22+
}
23+
24+
@Override
25+
protected List<ReactPackage> getPackages() {
26+
@SuppressWarnings("UnnecessaryLocalVariable")
27+
List<ReactPackage> packages = new PackageList(this).getPackages();
28+
// Packages that cannot be autolinked yet can be added manually here, for example:
29+
// packages.add(new MyReactNativePackage());
30+
return packages;
31+
}
32+
33+
@Override
34+
protected String getJSMainModuleName() {
35+
return "index";
36+
}
37+
};
3438

3539
@Override
3640
public ReactNativeHost getReactNativeHost() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

template/ios/HelloWorldTests/HelloWorldTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#import <React/RCTRootView.h>
1313

1414
#define TIMEOUT_SECONDS 600
15-
#define TEXT_TO_LOOK_FOR @"Welcome to React"
15+
#define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
1616

1717
@interface HelloWorldTests : XCTestCase
1818

template/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
"test": "jest"
88
},
99
"dependencies": {
10-
"react": "16.8.1",
11-
"react-native": "0.60.0"
10+
"react": "16.8.6",
11+
"react-native": "0.60.3"
1212
},
1313
"devDependencies": {
14-
"@babel/core": "^7.3.3",
15-
"@babel/runtime": "^7.3.1",
14+
"@babel/core": "^7.5.0",
15+
"@babel/runtime": "^7.5.0",
1616
"@react-native-community/eslint-config": "^0.0.3",
1717
"@types/jest": "^24.0.15",
1818
"@types/react": "^16.8.23",
19-
"@types/react-native": "^0.57.65",
19+
"@types/react-native": "^0.60.1",
2020
"@types/react-test-renderer": "^16.8.2",
2121
"babel-jest": "^24.1.0",
2222
"jest": "^24.1.0",
23-
"metro-react-native-babel-preset": "^0.51.1",
24-
"react-test-renderer": "16.8.1",
25-
"typescript": "^3.5.2"
23+
"metro-react-native-babel-preset": "^0.54.1",
24+
"react-test-renderer": "16.8.6",
25+
"typescript": "^3.5.3"
2626
},
2727
"jest": {
2828
"preset": "react-native",

template/tsconfig.json

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

0 commit comments

Comments
 (0)