diff --git a/lib/cli-command.js b/lib/cli-command.js index 3f562cc9..6378c960 100644 --- a/lib/cli-command.js +++ b/lib/cli-command.js @@ -100,6 +100,9 @@ ${postCreateInstructions(createOptions)}`); command: '--platforms ', description: 'Platforms the library module will be created for - comma separated', default: 'ios,android', + }, { + command: '--swift', + description: 'EXPERIMENAL: Generate the iOS native module in Swift', }, { command: '--tvos-enabled', description: 'Generate the module with tvOS build enabled (requires react-native-tvos fork, with minimum version of 0.60, and iOS platform to be enabled)', diff --git a/lib/lib.js b/lib/lib.js index 11bab795..d2a19623 100644 --- a/lib/lib.js +++ b/lib/lib.js @@ -80,6 +80,7 @@ const generateWithNormalizedOptions = ({ authorEmail = DEFAULT_AUTHOR_EMAIL, license = DEFAULT_LICENSE, isView = false, + swift = false, useAppleNetworking = false, generateExample = DEFAULT_GENERATE_EXAMPLE, exampleFileLinkage = false, @@ -109,6 +110,7 @@ const generateWithNormalizedOptions = ({ object class name: ${objectClassName} Android nativePackageId: ${nativePackageId} platforms: ${platforms} + use swift [iOS]: ${swift} Apple tvosEnabled: ${tvosEnabled} authorName: ${authorName} authorEmail: ${authorEmail} @@ -170,6 +172,7 @@ const generateWithNormalizedOptions = ({ authorEmail, license, isView, + swift, useAppleNetworking, }; diff --git a/templates/ios.js b/templates/ios.js index 17868f46..e063cf9d 100644 --- a/templates/ios.js +++ b/templates/ios.js @@ -33,8 +33,8 @@ end `, }, { - // header for module without view: - name: ({ objectClassName, isView }) => !isView && `${platform}/${objectClassName}.h`, + // header for Objective-C module without view: + name: ({ objectClassName, swift, isView }) => !swift && !isView && `${platform}/${objectClassName}.h`, content: ({ objectClassName }) => `// ${objectClassName}.h #import @@ -45,7 +45,7 @@ end `, }, { // implementation of module without view: - name: ({ objectClassName, isView }) => !isView && `${platform}/${objectClassName}.m`, + name: ({ objectClassName, swift, isView }) => !swift && !isView && `${platform}/${objectClassName}.m`, content: ({ objectClassName, useAppleNetworking }) => `// ${objectClassName}.m #import "${objectClassName}.h" @@ -77,6 +77,41 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu @end `, +}, { + // bridge header for Swift module without view: + name: ({ objectClassName, swift, view }) => swift && !view && `${platform}/${objectClassName}-Bridging-Header.h`, + content: ({ objectClassName }) => `// ${platform}/${objectClassName}-Bridging-Header.h +#import +`, +}, { + // bridge for Swift module without view: + name: ({ objectClassName, swift, view }) => swift && !view && `${platform}/${objectClassName}.m`, + content: ({ objectClassName, useAppleNetworking }) => `// ${objectClassName}.m + +#import + +@interface RCT_EXTERN_MODULE(${objectClassName}, NSObject) + +RCT_EXTERN_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnull NSNumber *)numberArgument callback:(RCTResponseSenderBlock)callback) + +@end +`, +}, { + // implementation of Swift module without view: + name: ({ objectClassName, swift, view }) => swift && !view && `${platform}/${objectClassName}.swift`, + content: ({ objectClassName, useAppleNetworking }) => `// ${objectClassName}.swift + +import Foundation + +@objc(${objectClassName}) +class ${objectClassName} : NSObject { + @objc(sampleMethod:numberParameter:callback:) + func sampleMethod(stringArgument: String, numberArgument: NSNumber, callback: RCTResponseSenderBlock) -> Void { + // TODO: Implement some actually useful functionality + callback([String(format: "numberArgument: %@ stringArgument: %@", numberArgument, stringArgument)]) + } +} +` }, { // header for module with view: name: ({ objectClassName, isView }) => isView && `${platform}/${objectClassName}.h`, diff --git a/tests/integration/cli/help/__snapshots__/cli-help.test.js.snap b/tests/integration/cli/help/__snapshots__/cli-help.test.js.snap index 439dfdeb..3258c626 100644 --- a/tests/integration/cli/help/__snapshots__/cli-help.test.js.snap +++ b/tests/integration/cli/help/__snapshots__/cli-help.test.js.snap @@ -12,6 +12,7 @@ Options: --object-class-name [objectClassName] The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase) --native-package-id [nativePackageId] [Android] The native Java package identifier used for Android (default: \\"com.reactlibrary\\") --platforms Platforms the library module will be created for - comma separated (default: \\"ios,android\\") + --swift EXPERIMENAL: Generate the iOS native module in Swift --tvos-enabled Generate the module with tvOS build enabled (requires react-native-tvos fork, with minimum version of 0.60, and iOS platform to be enabled) --github-account [githubAccount] The github account where the library module is hosted (default: \\"github_account\\") --author-name [authorName] The author's name (default: \\"Your Name\\") diff --git a/tests/integration/cli/noargs/__snapshots__/cli-noargs.test.js.snap b/tests/integration/cli/noargs/__snapshots__/cli-noargs.test.js.snap index 2941d7e2..a4d5c0b4 100644 --- a/tests/integration/cli/noargs/__snapshots__/cli-noargs.test.js.snap +++ b/tests/integration/cli/noargs/__snapshots__/cli-noargs.test.js.snap @@ -12,6 +12,7 @@ Options: --object-class-name [objectClassName] The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase) --native-package-id [nativePackageId] [Android] The native Java package identifier used for Android (default: \\"com.reactlibrary\\") --platforms Platforms the library module will be created for - comma separated (default: \\"ios,android\\") + --swift EXPERIMENAL: Generate the iOS native module in Swift --tvos-enabled Generate the module with tvOS build enabled (requires react-native-tvos fork, with minimum version of 0.60, and iOS platform to be enabled) --github-account [githubAccount] The github account where the library module is hosted (default: \\"github_account\\") --author-name [authorName] The author's name (default: \\"Your Name\\") diff --git a/tests/with-injection/cli/command/object/__snapshots__/lib-cli-command-object-text.test.js.snap b/tests/with-injection/cli/command/object/__snapshots__/lib-cli-command-object-text.test.js.snap index bdbf9b13..c5535087 100644 --- a/tests/with-injection/cli/command/object/__snapshots__/lib-cli-command-object-text.test.js.snap +++ b/tests/with-injection/cli/command/object/__snapshots__/lib-cli-command-object-text.test.js.snap @@ -28,6 +28,10 @@ Object { "default": "ios,android", "description": "Platforms the library module will be created for - comma separated", }, + Object { + "command": "--swift", + "description": "EXPERIMENAL: Generate the iOS native module in Swift", + }, Object { "command": "--tvos-enabled", "description": "Generate the module with tvOS build enabled (requires react-native-tvos fork, with minimum version of 0.60, and iOS platform to be enabled)", diff --git a/tests/with-injection/create/with-swift/__snapshots__/create-with-swift.test.js.snap b/tests/with-injection/create/with-swift/__snapshots__/create-with-swift.test.js.snap new file mode 100644 index 00000000..d5172d7b --- /dev/null +++ b/tests/with-injection/create/with-swift/__snapshots__/create-with-swift.test.js.snap @@ -0,0 +1,796 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`create alice-bobbi module with swift language 1`] = ` +Array [ + "* ensureDir dir: react-native-alice-bobbi +", + "* ensureDir dir: react-native-alice-bobbi/ +", + "* ensureDir dir: react-native-alice-bobbi/ +", + "* ensureDir dir: react-native-alice-bobbi/ +", + "* ensureDir dir: react-native-alice-bobbi/ +", + "* ensureDir dir: react-native-alice-bobbi/android/ +", + "* ensureDir dir: react-native-alice-bobbi/android/src/main/ +", + "* ensureDir dir: react-native-alice-bobbi/android/src/main/java/com/reactlibrary/ +", + "* ensureDir dir: react-native-alice-bobbi/android/src/main/java/com/reactlibrary/ +", + "* ensureDir dir: react-native-alice-bobbi/android/ +", + "* ensureDir dir: react-native-alice-bobbi/ +", + "* ensureDir dir: react-native-alice-bobbi/ios/ +", + "* ensureDir dir: react-native-alice-bobbi/ios/ +", + "* ensureDir dir: react-native-alice-bobbi/ios/ +", + "* ensureDir dir: react-native-alice-bobbi/ios/AliceBobbi.xcworkspace/ +", + "* ensureDir dir: react-native-alice-bobbi/ios/AliceBobbi.xcodeproj/ +", + "* outputFile name: react-native-alice-bobbi/README.md +content: +-------- +# react-native-alice-bobbi + +## Getting started + +\`$ npm install react-native-alice-bobbi --save\` + +### Mostly automatic installation + +\`$ react-native link react-native-alice-bobbi\` + +## Usage +\`\`\`javascript +import AliceBobbi from 'react-native-alice-bobbi'; + +// TODO: What to do with the module? +AliceBobbi; +\`\`\` + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/package.json +content: +-------- +{ + \\"name\\": \\"react-native-alice-bobbi\\", + \\"title\\": \\"React Native Alice Bobbi\\", + \\"version\\": \\"1.0.0\\", + \\"description\\": \\"TODO\\", + \\"main\\": \\"index.js\\", + \\"files\\": [ + \\"README.md\\", + \\"android\\", + \\"index.js\\", + \\"ios\\", + \\"react-native-alice-bobbi.podspec\\" + ], + \\"scripts\\": { + \\"test\\": \\"echo \\\\\\"Error: no test specified\\\\\\" && exit 1\\" + }, + \\"repository\\": { + \\"type\\": \\"git\\", + \\"url\\": \\"git+https://github.com/github_account/react-native-alice-bobbi.git\\", + \\"baseUrl\\": \\"https://github.com/github_account/react-native-alice-bobbi\\" + }, + \\"keywords\\": [ + \\"react-native\\" + ], + \\"author\\": { + \\"name\\": \\"Your Name\\", + \\"email\\": \\"yourname@email.com\\" + }, + \\"license\\": \\"MIT\\", + \\"licenseFilename\\": \\"LICENSE\\", + \\"readmeFilename\\": \\"README.md\\", + \\"peerDependencies\\": { + \\"react\\": \\">=16.8.1\\", + \\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\" + }, + \\"devDependencies\\": { + \\"react\\": \\"^16.9.0\\", + \\"react-native\\": \\"^0.61.5\\" + } +} + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/index.js +content: +-------- +// main index.js + +import { NativeModules } from 'react-native'; + +const { AliceBobbi } = NativeModules; + +export default AliceBobbi; + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/.gitignore +content: +-------- +# OSX +# +.DS_Store + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml + +# BUCK +buck-out/ +\\\\.buckd/ +*.keystore + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/android/build.gradle +content: +-------- +// android/build.gradle + +// based on: +// +// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle +// previous location: +// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle +// +// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle +// previous location: +// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle + +// These defaults should reflect the SDK versions used by +// the minimum React Native version supported. +def DEFAULT_COMPILE_SDK_VERSION = 28 +def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3' +def DEFAULT_MIN_SDK_VERSION = 16 +def DEFAULT_TARGET_SDK_VERSION = 28 + +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} + +apply plugin: 'com.android.library' +apply plugin: 'maven' + +buildscript { + // The Android Gradle plugin is only required when opening the android folder stand-alone. + // This avoids unnecessary downloads and potential conflicts when the library is included as a + // module dependency in an application project. + // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies + if (project == rootProject) { + repositories { + google() + } + dependencies { + // This should reflect the Gradle plugin version used by + // the minimum React Native version supported. + classpath 'com.android.tools.build:gradle:3.4.1' + } + } +} + +android { + compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) + buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) + defaultConfig { + minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) + targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) + versionCode 1 + versionName \\"1.0\\" + } + lintOptions { + abortOnError false + } +} + +repositories { + // ref: https://www.baeldung.com/maven-local-repository + mavenLocal() + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" + } + google() +} + +dependencies { + //noinspection GradleDynamicVersion + implementation 'com.facebook.react:react-native:+' // From node_modules +} + +def configureReactNativePom(def pom) { + def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text) + + pom.project { + name packageJson.title + artifactId packageJson.name + version = packageJson.version + group = \\"com.reactlibrary\\" + description packageJson.description + url packageJson.repository.baseUrl + + licenses { + license { + name packageJson.license + url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename + distribution 'repo' + } + } + + developers { + developer { + id packageJson.author.username + name packageJson.author.name + } + } + } +} + +afterEvaluate { project -> + // some Gradle build hooks ref: + // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html + task androidJavadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += files(android.bootClasspath) + classpath += files(project.getConfigurations().getByName('compile').asList()) + include '**/*.java' + } + + task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { + classifier = 'javadoc' + from androidJavadoc.destinationDir + } + + task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs + include '**/*.java' + } + + android.libraryVariants.all { variant -> + def name = variant.name.capitalize() + def javaCompileTask = variant.javaCompileProvider.get() + + task \\"jar\${name}\\"(type: Jar, dependsOn: javaCompileTask) { + from javaCompileTask.destinationDir + } + } + + artifacts { + archives androidSourcesJar + archives androidJavadocJar + } + + task installArchives(type: Upload) { + configuration = configurations.archives + repositories.mavenDeployer { + // Deploy to react-native-event-bridge/maven, ready to publish to npm + repository url: \\"file://\${projectDir}/../android/maven\\" + configureReactNativePom pom + } + } +} + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/android/src/main/AndroidManifest.xml +content: +-------- + + + + + + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/android/src/main/java/com/reactlibrary/AliceBobbiModule.java +content: +-------- +// AliceBobbiModule.java + +package com.reactlibrary; + +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactContextBaseJavaModule; +import com.facebook.react.bridge.ReactMethod; +import com.facebook.react.bridge.Callback; + +public class AliceBobbiModule extends ReactContextBaseJavaModule { + + private final ReactApplicationContext reactContext; + + public AliceBobbiModule(ReactApplicationContext reactContext) { + super(reactContext); + this.reactContext = reactContext; + } + + @Override + public String getName() { + return \\"AliceBobbi\\"; + } + + @ReactMethod + public void sampleMethod(String stringArgument, int numberArgument, Callback callback) { + // TODO: Implement some actually useful functionality + callback.invoke(\\"Received numberArgument: \\" + numberArgument + \\" stringArgument: \\" + stringArgument); + } +} + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/android/src/main/java/com/reactlibrary/AliceBobbiPackage.java +content: +-------- +// AliceBobbiPackage.java + +package com.reactlibrary; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; + +public class AliceBobbiPackage implements ReactPackage { + @Override + public List createNativeModules(ReactApplicationContext reactContext) { + return Arrays.asList(new AliceBobbiModule(reactContext)); + } + + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } +} + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/android/README.md +content: +-------- +README +====== + +If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: + +1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed +2. Be sure to have a \`local.properties\` file in this folder that points to the Android SDK and NDK +\`\`\` +ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle +sdk.dir=/Users/{username}/Library/Android/sdk +\`\`\` +3. Delete the \`maven\` folder +4. Run \`./gradlew installArchives\` +5. Verify that latest set of generated files is in the maven folder with the correct version number + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/react-native-alice-bobbi.podspec +content: +-------- +# react-native-alice-bobbi.podspec + +require \\"json\\" + +package = JSON.parse(File.read(File.join(__dir__, \\"package.json\\"))) + +Pod::Spec.new do |s| + s.name = \\"react-native-alice-bobbi\\" + s.version = package[\\"version\\"] + s.summary = package[\\"description\\"] + s.description = <<-DESC + react-native-alice-bobbi + DESC + s.homepage = \\"https://github.com/github_account/react-native-alice-bobbi\\" + # brief license entry: + s.license = \\"MIT\\" + # optional - use expanded license entry instead: + # s.license = { :type => \\"MIT\\", :file => \\"LICENSE\\" } + s.authors = { \\"Your Name\\" => \\"yourname@email.com\\" } + s.platforms = { :ios => \\"9.0\\" } + s.source = { :git => \\"https://github.com/github_account/react-native-alice-bobbi.git\\", :tag => \\"#{s.version}\\" } + + s.source_files = \\"ios/**/*.{h,c,cc,cpp,m,mm,swift}\\" + s.requires_arc = true + + s.dependency \\"React\\" + # ... + # s.dependency \\"...\\" +end + + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/ios/AliceBobbi-Bridging-Header.h +content: +-------- +// ios/AliceBobbi-Bridging-Header.h +#import + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/ios/AliceBobbi.m +content: +-------- +// AliceBobbi.m + +#import + +@interface RCT_EXTERN_MODULE(AliceBobbi, NSObject) + +RCT_EXTERN_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnull NSNumber *)numberArgument callback:(RCTResponseSenderBlock)callback) + +@end + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/ios/AliceBobbi.swift +content: +-------- +// AliceBobbi.swift + +import Foundation + +@objc(AliceBobbi) +class AliceBobbi : NSObject { + @objc(sampleMethod:numberParameter:callback:) + func sampleMethod(stringArgument: String, numberArgument: NSNumber, callback: RCTResponseSenderBlock) -> Void { + // TODO: Implement some actually useful functionality + callback([String(format: \\"numberArgument: %@ stringArgument: %@\\", numberArgument, stringArgument)]) + } +} + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/ios/AliceBobbi.xcworkspace/contents.xcworkspacedata +content: +-------- + + + + + + +<<<<<<<< ======== >>>>>>>> +", + "* outputFile name: react-native-alice-bobbi/ios/AliceBobbi.xcodeproj/project.pbxproj +content: +-------- +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* 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 /* libAliceBobbi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAliceBobbi.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* 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 /* libAliceBobbi.a */, + ); + name = Products; + sourceTree = \\"\\"; + }; + 58B511D21A9E6C8500147676 = { + isa = PBXGroup; + children = ( + 134814211AA4EA7D00B7C361 /* Products */, + ); + sourceTree = \\"\\"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 58B511DA1A9E6C8500147676 /* AliceBobbi */ = { + isa = PBXNativeTarget; + buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget \\"AliceBobbi\\" */; + buildPhases = ( + 58B511D71A9E6C8500147676 /* Sources */, + 58B511D81A9E6C8500147676 /* Frameworks */, + 58B511D91A9E6C8500147676 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AliceBobbi; + productName = RCTDataManager; + productReference = 134814201AA4EA6300B7C361 /* libAliceBobbi.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 \\"AliceBobbi\\" */; + compatibilityVersion = \\"Xcode 3.2\\"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 58B511D21A9E6C8500147676; + productRefGroup = 58B511D21A9E6C8500147676; + projectDirPath = \\"\\"; + projectRoot = \\"\\"; + targets = ( + 58B511DA1A9E6C8500147676 /* AliceBobbi */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 58B511D71A9E6C8500147676 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 58B511ED1A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + 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_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = 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 = 9.0; + LD_RUNPATH_SEARCH_PATHS = \\"/usr/lib/swift $(inherited)\\"; + LIBRARY_SEARCH_PATHS = ( + \\"\\\\\\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\\\\\\"\\", + \\"\\\\\\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\\\\\\"\\", + \\"\\\\\\"$(inherited)\\\\\\"\\", + ); + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 58B511EE1A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + 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_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = 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 = 9.0; + LD_RUNPATH_SEARCH_PATHS = \\"/usr/lib/swift $(inherited)\\"; + LIBRARY_SEARCH_PATHS = ( + \\"\\\\\\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\\\\\\"\\", + \\"\\\\\\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\\\\\\"\\", + \\"\\\\\\"$(inherited)\\\\\\"\\", + ); + 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 = AliceBobbi; + SKIP_INSTALL = YES; + }; + 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 = AliceBobbi; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject \\"AliceBobbi\\" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511ED1A9E6C8500147676 /* Debug */, + 58B511EE1A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget \\"AliceBobbi\\" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511F01A9E6C8500147676 /* Debug */, + 58B511F11A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 58B511D31A9E6C8500147676 /* Project object */; +} + +<<<<<<<< ======== >>>>>>>> +", +] +`; diff --git a/tests/with-injection/create/with-swift/create-with-swift.test.js b/tests/with-injection/create/with-swift/create-with-swift.test.js new file mode 100644 index 00000000..048ec778 --- /dev/null +++ b/tests/with-injection/create/with-swift/create-with-swift.test.js @@ -0,0 +1,17 @@ +const lib = require('../../../../lib/lib.js'); + +const ioInject = require('../../helpers/io-inject.js'); + +test('create alice-bobbi module with swift language', () => { + const mysnap = []; + + const inject = ioInject(mysnap); + + const options = { + name: 'alice-bobbi', + swift: true + }; + + return lib(options, inject) + .then(() => { expect(mysnap).toMatchSnapshot(); }); +}); diff --git a/tests/with-mocks/cli/command/action-func/with-logging/with-bogus-platforms/bogus-name/__snapshots__/cli-command-with-bogus-platforms-name.test.js.snap b/tests/with-mocks/cli/command/action-func/with-logging/with-bogus-platforms/bogus-name/__snapshots__/cli-command-with-bogus-platforms-name.test.js.snap index 3432781c..83077545 100644 --- a/tests/with-mocks/cli/command/action-func/with-logging/with-bogus-platforms/bogus-name/__snapshots__/cli-command-with-bogus-platforms-name.test.js.snap +++ b/tests/with-mocks/cli/command/action-func/with-logging/with-bogus-platforms/bogus-name/__snapshots__/cli-command-with-bogus-platforms-name.test.js.snap @@ -18,6 +18,7 @@ Array [ object class name: AliceBobbi Android nativePackageId: com.reactlibrary platforms: bogus + use swift [iOS]: false Apple tvosEnabled: false authorName: Your Name authorEmail: yourname@email.com diff --git a/tests/with-mocks/cli/command/action-func/with-logging/with-bogus-platforms/empty-string/__snapshots__/cli-command-with-empty-platforms-string.test.js.snap b/tests/with-mocks/cli/command/action-func/with-logging/with-bogus-platforms/empty-string/__snapshots__/cli-command-with-empty-platforms-string.test.js.snap index 06069357..ecc66fd7 100644 --- a/tests/with-mocks/cli/command/action-func/with-logging/with-bogus-platforms/empty-string/__snapshots__/cli-command-with-empty-platforms-string.test.js.snap +++ b/tests/with-mocks/cli/command/action-func/with-logging/with-bogus-platforms/empty-string/__snapshots__/cli-command-with-empty-platforms-string.test.js.snap @@ -18,6 +18,7 @@ Array [ object class name: AliceBobbi Android nativePackageId: com.reactlibrary platforms: + use swift [iOS]: false Apple tvosEnabled: false authorName: Your Name authorEmail: yourname@email.com diff --git a/tests/with-mocks/cli/command/action-func/with-logging/with-error/__snapshots__/cli-command-with-logging-with-error.test.js.snap b/tests/with-mocks/cli/command/action-func/with-logging/with-error/__snapshots__/cli-command-with-logging-with-error.test.js.snap index 14adcc70..e20fa29b 100644 --- a/tests/with-mocks/cli/command/action-func/with-logging/with-error/__snapshots__/cli-command-with-logging-with-error.test.js.snap +++ b/tests/with-mocks/cli/command/action-func/with-logging/with-error/__snapshots__/cli-command-with-logging-with-error.test.js.snap @@ -18,6 +18,7 @@ Array [ object class name: AliceBobbi Android nativePackageId: com.reactlibrary platforms: android,ios + use swift [iOS]: false Apple tvosEnabled: false authorName: Your Name authorEmail: yourname@email.com diff --git a/tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap b/tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap index 5be7766a..0fe2af22 100644 --- a/tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap +++ b/tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap @@ -77,6 +77,16 @@ Array [ ], }, }, + Object { + "option": Object { + "args": Array [ + "--swift", + "EXPERIMENAL: Generate the iOS native module in Swift", + [Function], + undefined, + ], + }, + }, Object { "option": Object { "args": Array [ diff --git a/tests/with-mocks/cli/program/with-example/with-logging/__snapshots__/cli-program-with-example-with-logging.test.js.snap b/tests/with-mocks/cli/program/with-example/with-logging/__snapshots__/cli-program-with-example-with-logging.test.js.snap index 5a820b0d..2bda89c5 100644 --- a/tests/with-mocks/cli/program/with-example/with-logging/__snapshots__/cli-program-with-example-with-logging.test.js.snap +++ b/tests/with-mocks/cli/program/with-example/with-logging/__snapshots__/cli-program-with-example-with-logging.test.js.snap @@ -77,6 +77,16 @@ Array [ ], }, }, + Object { + "option": Object { + "args": Array [ + "--swift", + "EXPERIMENAL: Generate the iOS native module in Swift", + [Function], + undefined, + ], + }, + }, Object { "option": Object { "args": Array [ @@ -212,6 +222,7 @@ Array [ object class name: TestPackage Android nativePackageId: com.reactlibrary platforms: android,ios + use swift [iOS]: false Apple tvosEnabled: false authorName: Your Name authorEmail: yourname@email.com diff --git a/tests/with-mocks/cli/program/with-missing-args/__snapshots__/cli-program-with-missing-args.test.js.snap b/tests/with-mocks/cli/program/with-missing-args/__snapshots__/cli-program-with-missing-args.test.js.snap index 1717a44f..97e73d5c 100644 --- a/tests/with-mocks/cli/program/with-missing-args/__snapshots__/cli-program-with-missing-args.test.js.snap +++ b/tests/with-mocks/cli/program/with-missing-args/__snapshots__/cli-program-with-missing-args.test.js.snap @@ -75,6 +75,16 @@ Array [ ], }, }, + Object { + "option": Object { + "args": Array [ + "--swift", + "EXPERIMENAL: Generate the iOS native module in Swift", + [Function], + undefined, + ], + }, + }, Object { "option": Object { "args": Array [ diff --git a/tests/with-mocks/lib/create/with-example/with-logging/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap b/tests/with-mocks/lib/create/with-example/with-logging/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap index 322d3b42..8be109ca 100644 --- a/tests/with-mocks/lib/create/with-example/with-logging/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap +++ b/tests/with-mocks/lib/create/with-example/with-logging/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap @@ -18,6 +18,7 @@ Array [ object class name: AliceBobbi Android nativePackageId: com.reactlibrary platforms: android,ios + use swift [iOS]: false Apple tvosEnabled: false authorName: Your Name authorEmail: yourname@email.com diff --git a/tests/with-mocks/lib/create/with-example/with-logging/with-error/__snapshots__/with-yarn-error-logging.test.js.snap b/tests/with-mocks/lib/create/with-example/with-logging/with-error/__snapshots__/with-yarn-error-logging.test.js.snap index e6344e4c..95ebfd3e 100644 --- a/tests/with-mocks/lib/create/with-example/with-logging/with-error/__snapshots__/with-yarn-error-logging.test.js.snap +++ b/tests/with-mocks/lib/create/with-example/with-logging/with-error/__snapshots__/with-yarn-error-logging.test.js.snap @@ -18,6 +18,7 @@ Array [ object class name: AliceBobbi Android nativePackageId: com.reactlibrary platforms: android,ios + use swift [iOS]: false Apple tvosEnabled: false authorName: Your Name authorEmail: yourname@email.com diff --git a/tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap b/tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap index 15d5297d..48f055bc 100644 --- a/tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap +++ b/tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap @@ -12,6 +12,7 @@ Array [ object class name: AliceBobbi Android nativePackageId: com.alicebits platforms: android,ios + use swift [iOS]: false Apple tvosEnabled: true authorName: Alice authorEmail: contact@alice.me