diff --git a/packages/create-react-native-library/src/index.ts b/packages/create-react-native-library/src/index.ts index e2b3277c1..cfe71c2a2 100644 --- a/packages/create-react-native-library/src/index.ts +++ b/packages/create-react-native-library/src/index.ts @@ -16,14 +16,18 @@ const JS_FILES = path.resolve(__dirname, '../templates/js-library'); const EXPO_FILES = path.resolve(__dirname, '../templates/expo-library'); const CPP_FILES = path.resolve(__dirname, '../templates/cpp-library'); const EXAMPLE_FILES = path.resolve(__dirname, '../templates/example'); +const NATIVE_COMMON_FILES = path.resolve( + __dirname, + '../templates/native-common' +); -// Android -const NATIVE_FILES = (moduleType: ModuleType) => { +// Java +const JAVA_FILES = (moduleType: ModuleType) => { switch (moduleType) { case 'module': - return path.resolve(__dirname, '../templates/native-library'); + return path.resolve(__dirname, '../templates/java-library'); case 'view': - return path.resolve(__dirname, '../templates/native-view-library'); + return path.resolve(__dirname, '../templates/java-view-library'); } }; @@ -37,6 +41,16 @@ const OBJC_FILES = (moduleType: ModuleType) => { } }; +// Kotlin +const KOTLIN_FILES = (moduleType: ModuleType) => { + switch (moduleType) { + case 'module': + return path.resolve(__dirname, '../templates/kotlin-library'); + case 'view': + return path.resolve(__dirname, '../templates/kotlin-view-library'); + } +}; + // Swift const SWIFT_FILES = (moduleType: ModuleType) => { switch (moduleType) { @@ -59,12 +73,16 @@ type ArgName = type ModuleType = 'module' | 'view'; type LibraryType = - | 'native-view' - | 'native-view-swift' | 'native' | 'native-swift' - | 'js' + | 'native-kotlin' + | 'native-kotlin-swift' + | 'native-view' + | 'native-view-swift' + | 'native-view-kotlin' + | 'native-view-kotlin-swift' | 'cpp' + | 'js' | 'expo'; type Answers = { @@ -104,7 +122,19 @@ const args: Record = { }, 'type': { description: 'Type package do you want to develop', - choices: ['native', 'native-swift', 'js', 'cpp', 'expo'], + choices: [ + 'native', + 'native-swift', + 'native-kotlin', + 'native-kotlin-swift', + 'native-view', + 'native-view-swift', + 'native-view-kotlin', + 'native-view-kotlin-swift', + 'cpp', + 'js', + 'expo', + ], }, }; @@ -218,17 +248,33 @@ async function create(argv: yargs.Arguments) { name: 'type', message: 'What type of package do you want to develop?', choices: [ - { title: 'Native module in Kotlin and Objective-C', value: 'native' }, - { title: 'Native module in Kotlin and Swift', value: 'native-swift' }, + { title: 'Native module in Java and Objective-C', value: 'native' }, + { title: 'Native module in Java and Swift', value: 'native-swift' }, + { + title: 'Native module in Kotlin and Objective-C', + value: 'native-kotlin', + }, + { + title: 'Native module in Kotlin and Swift', + value: 'native-kotlin-swift', + }, { title: 'Native module with C++ code', value: 'cpp' }, { - title: 'Native view in Kotlin and Objective-C', + title: 'Native view in Java and Objective-C', value: 'native-view', }, { - title: 'Native view in Kotlin and Swift', + title: 'Native view in Java and Swift', value: 'native-view-swift', }, + { + title: 'Native view in Kotlin and Objective-C', + value: 'native-view-kotlin', + }, + { + title: 'Native view in Kotlin and Swift', + value: 'native-view-kotlin-swift', + }, { title: 'JavaScript library with native example', value: 'js', @@ -265,7 +311,12 @@ async function create(argv: yargs.Arguments) { const project = slug.replace(/^(react-native-|@[^/]+\/)/, ''); const moduleType: ModuleType = - type === 'native-view' || type === 'native-view-swift' ? 'view' : 'module'; + type === 'native-view' || + type === 'native-view-swift' || + type === 'native-view-kotlin' || + type === 'native-view-kotlin-swift' + ? 'view' + : 'module'; // Get latest version of Bob from NPM let version: string; @@ -308,13 +359,26 @@ async function create(argv: yargs.Arguments) { package: slug.replace(/[^a-z0-9]/g, '').toLowerCase(), podspec: slug.replace(/[^a-z0-9]+/g, '-').replace(/^-/, ''), native: - type === 'native' || type === 'cpp' || - 'native-swift' || - 'native-view' || - 'native-view-swift', + type === 'native' || + type === 'native-swift' || + type === 'native-kotlin' || + type === 'native-kotlin-swift' || + type === 'native-view' || + type === 'native-view-swift' || + type === 'native-view-kotlin' || + type === 'native-view-kotlin-swift', cpp: type === 'cpp', - swift: type === 'native-swift' || 'native-view-swift', + kotlin: + type === 'native-kotlin' || + type === 'native-kotlin-swift' || + type === 'native-view-kotlin' || + type === 'native-view-kotlin-swift', + swift: + type === 'native-swift' || + type === 'native-kotlin-swift' || + type === 'native-view-swift' || + type === 'native-view-kotlin-swift', module: type !== 'js', moduleType, }, @@ -372,15 +436,22 @@ async function create(argv: yargs.Arguments) { path.join(folder, 'example') ); - await copyDir(NATIVE_FILES(moduleType), folder); + await copyDir(NATIVE_COMMON_FILES, folder); - if (type === 'cpp') { + if (options.project.cpp) { await copyDir(CPP_FILES, folder); - } else if (type === 'native-swift') { + } + + if (options.project.swift) { await copyDir(SWIFT_FILES(moduleType), folder); } else { await copyDir(OBJC_FILES(moduleType), folder); } + if (options.project.kotlin) { + await copyDir(KOTLIN_FILES(moduleType), folder); + } else { + await copyDir(JAVA_FILES(moduleType), folder); + } } try { diff --git a/packages/create-react-native-library/templates/java-library/android/build.gradle b/packages/create-react-native-library/templates/java-library/android/build.gradle new file mode 100644 index 000000000..ec8449085 --- /dev/null +++ b/packages/create-react-native-library/templates/java-library/android/build.gradle @@ -0,0 +1,71 @@ +buildscript { + if (project == rootProject) { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.5.3' + } + } +} + +apply plugin: 'com.android.library' + +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} + +android { + compileSdkVersion safeExtGet('<%- project.name %>_compileSdkVersion', 29) + buildToolsVersion safeExtGet('<%- project.name %>_buildToolsVersion', '29.0.2') + defaultConfig { + minSdkVersion safeExtGet('<%- project.name %>_minSdkVersion', 16) + targetSdkVersion safeExtGet('<%- project.name %>_targetSdkVersion', 29) + versionCode 1 + versionName "1.0" +<% if (project.cpp) { %> + externalNativeBuild { + cmake { + cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all" + abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' + } + } +<% } %> + } +<% if (project.cpp) { %> + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +<% } %> + buildTypes { + release { + minifyEnabled false + } + } + lintOptions { + disable 'GradleCompatible' + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +repositories { + mavenLocal() + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url("$rootDir/../node_modules/react-native/android") + } + google() + jcenter() +} + +dependencies { + //noinspection GradleDynamicVersion + implementation "com.facebook.react:react-native:+" // From node_modules +} diff --git a/packages/create-react-native-library/templates/java-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Module.java b/packages/create-react-native-library/templates/java-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Module.java new file mode 100644 index 000000000..f92f0ce14 --- /dev/null +++ b/packages/create-react-native-library/templates/java-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Module.java @@ -0,0 +1,47 @@ +package com.<%- project.package %>; + +import androidx.annotation.NonNull; + +import com.facebook.react.bridge.Promise; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactContextBaseJavaModule; +import com.facebook.react.bridge.ReactMethod; +import com.facebook.react.module.annotations.ReactModule; + +@ReactModule(name = <%- project.name %>Module.NAME) +public class <%- project.name %>Module extends ReactContextBaseJavaModule { + public static final String NAME = "<%- project.name %>"; + + public <%- project.name %>Module(ReactApplicationContext reactContext) { + super(reactContext); + } + + @Override + @NonNull + public String getName() { + return NAME; + } + +<% if (project.cpp) { -%> + static { + try { + // Used to load the 'native-lib' library on application startup. + System.loadLibrary("cpp"); + } catch (Exception ignored) { + } + } +<% } -%> + + // Example method + // See https://reactnative.dev/docs/native-modules-android + @ReactMethod + public void multiply(int a, int b, Promise promise) { +<% if (project.cpp) { -%> + promise.resolve(nativeMultiply(a, b)); +<% } else { -%> + promise.resolve(a * b); +<% } -%> + } + + public static native int nativeMultiply(int a, int b); +} diff --git a/packages/create-react-native-library/templates/java-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.java b/packages/create-react-native-library/templates/java-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.java new file mode 100644 index 000000000..92eb92e93 --- /dev/null +++ b/packages/create-react-native-library/templates/java-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.java @@ -0,0 +1,28 @@ +package com.<%- project.package %>; + +import androidx.annotation.NonNull; + +import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class <%- project.name %>Package implements ReactPackage { + @NonNull + @Override + public List createNativeModules(@NonNull ReactApplicationContext reactContext) { + List modules = new ArrayList<>(); + modules.add(new <%- project.name %>Module(reactContext)); + return modules; + } + + @NonNull + @Override + public List createViewManagers(@NonNull ReactApplicationContext reactContext) { + return Collections.emptyList(); + } +} diff --git a/packages/create-react-native-library/templates/java-view-library/android/build.gradle b/packages/create-react-native-library/templates/java-view-library/android/build.gradle new file mode 100644 index 000000000..ec8449085 --- /dev/null +++ b/packages/create-react-native-library/templates/java-view-library/android/build.gradle @@ -0,0 +1,71 @@ +buildscript { + if (project == rootProject) { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.5.3' + } + } +} + +apply plugin: 'com.android.library' + +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} + +android { + compileSdkVersion safeExtGet('<%- project.name %>_compileSdkVersion', 29) + buildToolsVersion safeExtGet('<%- project.name %>_buildToolsVersion', '29.0.2') + defaultConfig { + minSdkVersion safeExtGet('<%- project.name %>_minSdkVersion', 16) + targetSdkVersion safeExtGet('<%- project.name %>_targetSdkVersion', 29) + versionCode 1 + versionName "1.0" +<% if (project.cpp) { %> + externalNativeBuild { + cmake { + cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all" + abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' + } + } +<% } %> + } +<% if (project.cpp) { %> + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } +<% } %> + buildTypes { + release { + minifyEnabled false + } + } + lintOptions { + disable 'GradleCompatible' + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +repositories { + mavenLocal() + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url("$rootDir/../node_modules/react-native/android") + } + google() + jcenter() +} + +dependencies { + //noinspection GradleDynamicVersion + implementation "com.facebook.react:react-native:+" // From node_modules +} diff --git a/packages/create-react-native-library/templates/java-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.java b/packages/create-react-native-library/templates/java-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.java new file mode 100644 index 000000000..fe248994b --- /dev/null +++ b/packages/create-react-native-library/templates/java-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.java @@ -0,0 +1,22 @@ +package com.<%- project.package %>; + +import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class <%- project.name %>Package implements ReactPackage { + @Override + public List createNativeModules(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } + + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Arrays.asList(new <%- project.name %>ViewManager()); + } +} diff --git a/packages/create-react-native-library/templates/java-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}ViewManager.java b/packages/create-react-native-library/templates/java-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}ViewManager.java new file mode 100644 index 000000000..347c58b88 --- /dev/null +++ b/packages/create-react-native-library/templates/java-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}ViewManager.java @@ -0,0 +1,31 @@ +package com.<%- project.package %>; + +import android.graphics.Color; +import android.view.View; + +import androidx.annotation.NonNull; + +import com.facebook.react.uimanager.SimpleViewManager; +import com.facebook.react.uimanager.ThemedReactContext; +import com.facebook.react.uimanager.annotations.ReactProp; + +public class <%- project.name %>ViewManager extends SimpleViewManager { + public static final String REACT_CLASS = "<%- project.name %>View"; + + @Override + @NonNull + public String getName() { + return REACT_CLASS; + } + + @Override + @NonNull + public View createViewInstance(ThemedReactContext reactContext) { + return new View(reactContext); + } + + @ReactProp(name = "color") + public void setColor(View view, String color) { + view.setBackgroundColor(Color.parseColor(color)); + } +} diff --git a/packages/create-react-native-library/templates/native-library/android/build.gradle b/packages/create-react-native-library/templates/kotlin-library/android/build.gradle similarity index 100% rename from packages/create-react-native-library/templates/native-library/android/build.gradle rename to packages/create-react-native-library/templates/kotlin-library/android/build.gradle diff --git a/packages/create-react-native-library/templates/native-library/android/gradle.properties b/packages/create-react-native-library/templates/kotlin-library/android/gradle.properties similarity index 100% rename from packages/create-react-native-library/templates/native-library/android/gradle.properties rename to packages/create-react-native-library/templates/kotlin-library/android/gradle.properties diff --git a/packages/create-react-native-library/templates/native-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Module.kt b/packages/create-react-native-library/templates/kotlin-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Module.kt similarity index 100% rename from packages/create-react-native-library/templates/native-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Module.kt rename to packages/create-react-native-library/templates/kotlin-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Module.kt diff --git a/packages/create-react-native-library/templates/native-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.kt b/packages/create-react-native-library/templates/kotlin-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.kt similarity index 100% rename from packages/create-react-native-library/templates/native-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.kt rename to packages/create-react-native-library/templates/kotlin-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.kt diff --git a/packages/create-react-native-library/templates/native-view-library/android/build.gradle b/packages/create-react-native-library/templates/kotlin-view-library/android/build.gradle similarity index 100% rename from packages/create-react-native-library/templates/native-view-library/android/build.gradle rename to packages/create-react-native-library/templates/kotlin-view-library/android/build.gradle diff --git a/packages/create-react-native-library/templates/native-view-library/android/gradle.properties b/packages/create-react-native-library/templates/kotlin-view-library/android/gradle.properties similarity index 100% rename from packages/create-react-native-library/templates/native-view-library/android/gradle.properties rename to packages/create-react-native-library/templates/kotlin-view-library/android/gradle.properties diff --git a/packages/create-react-native-library/templates/native-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.kt b/packages/create-react-native-library/templates/kotlin-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.kt similarity index 100% rename from packages/create-react-native-library/templates/native-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.kt rename to packages/create-react-native-library/templates/kotlin-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}Package.kt diff --git a/packages/create-react-native-library/templates/native-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}ViewManager.kt b/packages/create-react-native-library/templates/kotlin-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}ViewManager.kt similarity index 100% rename from packages/create-react-native-library/templates/native-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}ViewManager.kt rename to packages/create-react-native-library/templates/kotlin-view-library/android/src/main/java/com/{%- project.package %}/{%= project.name %}ViewManager.kt diff --git a/packages/create-react-native-library/templates/native-library/android/src/main/AndroidManifest.xml b/packages/create-react-native-library/templates/native-common/android/src/main/AndroidManifest.xml similarity index 100% rename from packages/create-react-native-library/templates/native-library/android/src/main/AndroidManifest.xml rename to packages/create-react-native-library/templates/native-common/android/src/main/AndroidManifest.xml diff --git a/packages/create-react-native-library/templates/native-library/ios/{%- project.name %}.xcodeproj/project.pbxproj b/packages/create-react-native-library/templates/native-common/ios/{%- project.name %}.xcodeproj/project.pbxproj similarity index 100% rename from packages/create-react-native-library/templates/native-library/ios/{%- project.name %}.xcodeproj/project.pbxproj rename to packages/create-react-native-library/templates/native-common/ios/{%- project.name %}.xcodeproj/project.pbxproj diff --git a/packages/create-react-native-library/templates/native-library/ios/{%- project.name %}.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/create-react-native-library/templates/native-common/ios/{%- project.name %}.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from packages/create-react-native-library/templates/native-library/ios/{%- project.name %}.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to packages/create-react-native-library/templates/native-common/ios/{%- project.name %}.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/packages/create-react-native-library/templates/native-common/src/index.tsx b/packages/create-react-native-library/templates/native-common/src/index.tsx new file mode 100644 index 000000000..fc32a0c65 --- /dev/null +++ b/packages/create-react-native-library/templates/native-common/src/index.tsx @@ -0,0 +1,24 @@ +<% if (project.moduleType === "view") { -%> +import { requireNativeComponent, ViewStyle } from 'react-native'; + +type <%- project.name %>Props = { + color: string; + style: ViewStyle; +}; + +export const <%- project.name %>ViewManager = requireNativeComponent<<%- project.name %>Props>( +'<%- project.name %>View' +); + +export default <%- project.name %>ViewManager; +<% } else { -%> +import { NativeModules } from 'react-native'; + +type <%- project.name %>Type = { + multiply(a: number, b: number): Promise; +}; + +const { <%- project.name %> } = NativeModules; + +export default <%- project.name %> as <%- project.name %>Type; +<% } -%> diff --git a/packages/create-react-native-library/templates/native-library/{%- project.podspec %}.podspec b/packages/create-react-native-library/templates/native-common/{%- project.podspec %}.podspec similarity index 100% rename from packages/create-react-native-library/templates/native-library/{%- project.podspec %}.podspec rename to packages/create-react-native-library/templates/native-common/{%- project.podspec %}.podspec diff --git a/packages/create-react-native-library/templates/native-library/src/index.tsx b/packages/create-react-native-library/templates/native-library/src/index.tsx deleted file mode 100644 index 772de011d..000000000 --- a/packages/create-react-native-library/templates/native-library/src/index.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { NativeModules } from 'react-native'; - -type <%- project.name %>Type = { - multiply(a: number, b: number): Promise; -}; - -const { <%- project.name %> } = NativeModules; - -export default <%- project.name %> as <%- project.name %>Type; diff --git a/packages/create-react-native-library/templates/native-view-library/android/src/main/AndroidManifest.xml b/packages/create-react-native-library/templates/native-view-library/android/src/main/AndroidManifest.xml deleted file mode 100644 index 564d53da9..000000000 --- a/packages/create-react-native-library/templates/native-view-library/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/packages/create-react-native-library/templates/native-view-library/ios/{%- project.name %}.xcodeproj/project.pbxproj b/packages/create-react-native-library/templates/native-view-library/ios/{%- project.name %}.xcodeproj/project.pbxproj deleted file mode 100644 index af178a29e..000000000 --- a/packages/create-react-native-library/templates/native-view-library/ios/{%- project.name %}.xcodeproj/project.pbxproj +++ /dev/null @@ -1,317 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ -<% if (project.cpp) { %> - 5E46D8CD2428F78900513E24 /* example.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E46D8CB2428F78900513E24 /* example.cpp */; }; - 5E555C0D2413F4C50049A1A2 /* <%- project.name %>.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* <%- project.name %>.mm */; }; -<% } else if (project.swift) { %> - 5E555C0D2413F4C50049A1A2 /* <%- project.name %>.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* <%- project.name %>.m */; }; - F4FF95D7245B92E800C19C63 /* <%- project.name %>.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* <%- project.name %>.swift */; }; -<% } else { %> - 5E555C0D2413F4C50049A1A2 /* <%- project.name %>.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* <%- project.name %>.m */; }; -<% } %> -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 134814201AA4EA6300B7C361 /* lib<%- project.name %>.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = lib<%- project.name %>.a; sourceTree = BUILT_PRODUCTS_DIR; }; -<% if (project.cpp) { %> - 5E46D8CB2428F78900513E24 /* example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = example.cpp; path = ../cpp/example.cpp; sourceTree = ""; }; - 5E46D8CC2428F78900513E24 /* example.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = example.h; path = ../cpp/example.h; sourceTree = ""; }; - B3E7B5891CC2AC0600A0062D /* <%- project.name %>.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = <%- project.name %>.mm; sourceTree = ""; }; -<% } else if (project.swift) { %> - B3E7B5891CC2AC0600A0062D /* <%- project.name %>.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = <%- project.name %>.m; sourceTree = ""; }; - F4FF95D5245B92E700C19C63 /* <%- project.name %>-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "<%- project.name %>-Bridging-Header.h"; sourceTree = ""; }; - F4FF95D6245B92E800C19C63 /* <%- project.name %>.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = <%- project.name %>.swift; sourceTree = ""; }; -<% } else { %> - B3E7B5881CC2AC0600A0062D /* <%- project.name %>.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = <%- project.name %>.h; sourceTree = ""; }; - B3E7B5891CC2AC0600A0062D /* <%- project.name %>.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = <%- project.name %>.m; sourceTree = ""; }; -<% } %> -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 134814211AA4EA7D00B7C361 /* Products */ = { - isa = PBXGroup; - children = ( - 134814201AA4EA6300B7C361 /* lib<%- project.name %>.a */, - ); - name = Products; - sourceTree = ""; - }; - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( -<% if (project.cpp) { %> - 5E46D8CB2428F78900513E24 /* example.cpp */, - 5E46D8CC2428F78900513E24 /* example.h */, - B3E7B5891CC2AC0600A0062D /* <%- project.name %>.mm */, -<% } else if (project.swift) { %> - F4FF95D6245B92E800C19C63 /* <%- project.name %>.swift */, - B3E7B5891CC2AC0600A0062D /* <%- project.name %>.m */, - F4FF95D5245B92E700C19C63 /* <%- project.name %>-Bridging-Header.h */, -<% } else { %> - B3E7B5881CC2AC0600A0062D /* <%- project.name %>.h */, - B3E7B5891CC2AC0600A0062D /* <%- project.name %>.m */, -<% } %> - 134814211AA4EA7D00B7C361 /* Products */, - ); - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* <%- project.name %> */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "<%- project.name %>" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = <%- project.name %>; - productName = RCTDataManager; - productReference = 134814201AA4EA6300B7C361 /* lib<%- project.name %>.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0920; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "<%- project.name %>" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - English, - en, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511D21A9E6C8500147676; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* <%- project.name %> */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( -<% if (project.cpp) { %> - 5E46D8CD2428F78900513E24 /* example.cpp in Sources */, - 5E555C0D2413F4C50049A1A2 /* <%- project.name %>.mm in Sources */, -<% } else if (project.swift) { %> - F4FF95D7245B92E800C19C63 /* <%- project.name %>.swift in Sources */, - B3E7B58A1CC2AC0600A0062D /* <%- project.name %>.m in Sources */, -<% } else { %> - B3E7B58A1CC2AC0600A0062D /* <%- project.name %>.m in Sources */, -<% } %> - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../../React/**", - "$(SRCROOT)/../../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = <%- project.name %>; - SKIP_INSTALL = YES; -<% if (project.swift) { %> - SWIFT_OBJC_BRIDGING_HEADER = "<%- project.name %>-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; -<% } %> - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../../React/**", - "$(SRCROOT)/../../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = <%- project.name %>; - SKIP_INSTALL = YES; -<% if (project.swift) { %> - SWIFT_OBJC_BRIDGING_HEADER = "<%- project.name %>-Bridging-Header.h"; - SWIFT_VERSION = 5.0; -<% } %> - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "<%- project.name %>" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "<%- project.name %>" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/packages/create-react-native-library/templates/native-view-library/ios/{%- project.name %}.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/create-react-native-library/templates/native-view-library/ios/{%- project.name %}.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 94b2795e2..000000000 --- a/packages/create-react-native-library/templates/native-view-library/ios/{%- project.name %}.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/packages/create-react-native-library/templates/native-view-library/src/index.tsx b/packages/create-react-native-library/templates/native-view-library/src/index.tsx deleted file mode 100644 index e95c8a56b..000000000 --- a/packages/create-react-native-library/templates/native-view-library/src/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { requireNativeComponent, ViewStyle } from 'react-native'; - -type <%- project.name %>Props = { - color: string; - style: ViewStyle; -}; - -export const <%- project.name %>ViewManager = requireNativeComponent<<%- project.name %>Props>( - '<%- project.name %>View' -); - -export default <%- project.name %>ViewManager; diff --git a/packages/create-react-native-library/templates/native-view-library/{%- project.podspec %}.podspec b/packages/create-react-native-library/templates/native-view-library/{%- project.podspec %}.podspec deleted file mode 100644 index 271e99bdc..000000000 --- a/packages/create-react-native-library/templates/native-view-library/{%- project.podspec %}.podspec +++ /dev/null @@ -1,25 +0,0 @@ -require "json" - -package = JSON.parse(File.read(File.join(__dir__, "package.json"))) - -Pod::Spec.new do |s| - s.name = "<%- project.podspec %>" - s.version = package["version"] - s.summary = package["description"] - s.homepage = package["homepage"] - s.license = package["license"] - s.authors = package["author"] - - s.platforms = { :ios => "10.0" } - s.source = { :git => "<%- repo %>.git", :tag => "#{s.version}" } - -<% if (project.cpp) { -%> - s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{h,cpp}" -<% } else if (project.swift) { -%> - s.source_files = "ios/**/*.{h,m,mm,swift}" -<% } else { -%> - s.source_files = "ios/**/*.{h,m,mm}" -<% } -%> - - s.dependency "React-Core" -end