Skip to content

Commit a4d2ba0

Browse files
author
Krzysztof
authored
fix: separate example app from native library files (#68)
# Summary Fixes #65 Separated Example app files from native library files. Conditional android package linking if project type is `js`. ## Checklist - [X] I have tested this
1 parent 05885c7 commit a4d2ba0

File tree

47 files changed

+109
-103
lines changed

Some content is hidden

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

47 files changed

+109
-103
lines changed

src/create.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const EXPO_FILES = path.resolve(__dirname, '../templates/expo-library');
1919
const CPP_FILES = path.resolve(__dirname, '../templates/cpp-library');
2020
const OBJC_FILES = path.resolve(__dirname, '../templates/objc-library');
2121
const SWIFT_FILES = path.resolve(__dirname, '../templates/swift-library');
22+
const EXAMPLE_FILES = path.resolve(__dirname, '../templates/example');
2223

2324
type ArgName =
2425
| 'slug'
@@ -275,10 +276,14 @@ export default async function create(argv: yargs.Arguments<any>) {
275276
} else if (type === 'js') {
276277
await copyDir(JS_FILES, folder);
277278
await copyDir(
278-
path.join(NATIVE_FILES, 'example'),
279+
path.join(EXAMPLE_FILES, 'example'),
279280
path.join(folder, 'example')
280281
);
281282
} else {
283+
await copyDir(
284+
path.join(EXAMPLE_FILES, 'example'),
285+
path.join(folder, 'example')
286+
);
282287
await copyDir(NATIVE_FILES, folder);
283288

284289
if (type === 'cpp') {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import com.facebook.soloader.SoLoader;
1111
import java.lang.reflect.InvocationTargetException;
1212
import java.util.List;
13-
13+
<% if (project.module) { -%>
1414
import com.<%= project.package %>.<%= project.name %>Package;
15+
<% } -%>
1516

1617
public class MainApplication extends Application implements ReactApplication {
1718

@@ -28,7 +29,7 @@ protected List<ReactPackage> getPackages() {
2829
List<ReactPackage> packages = new PackageList(this).getPackages();
2930
// Packages that cannot be autolinked yet can be added manually here, for <%= project.name %>Example:
3031
// packages.add(new MyReactNativePackage());
31-
packages.add(new <%= project.name %>Package());
32+
<% if (project.module) { -%>packages.add(new <%= project.name %>Package());<% } -%>
3233

3334
return packages;
3435
}

0 commit comments

Comments
 (0)