Skip to content

Commit

Permalink
v2.0 rn (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
laves committed Nov 25, 2023
1 parent 6d4704a commit 4c137f4
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 495 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/react-native-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ jobs:
- name: Pre-build dependencies
run: npm install yarn

# ************ REMOVE AFTER RELEASE *****************
- name: Build and package binding
working-directory: binding/react-native
run: yarn && yarn pkg

- name: Add to demo
run: yarn add ../../binding/react-native/pkg/picovoice-cheetah-react-native-2.0.0.tgz
# ***************************************************

- name: Install dependencies
run: yarn android-install

Expand Down Expand Up @@ -66,6 +75,15 @@ jobs:
- name: Pre-build dependencies
run: npm install yarn

# ************ REMOVE AFTER RELEASE *****************
- name: Build and package binding
working-directory: binding/react-native
run: yarn && yarn pkg

- name: Add to demo
run: yarn add ../../binding/react-native/pkg/picovoice-cheetah-react-native-2.0.0.tgz
# ***************************************************

- name: Install dependencies
run: yarn ios-install

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/react-native-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
./copy_test_resources.sh
- name: Cocoapods install
working-directory: binding/react-native/test-app/CheetahTestApp/ios
run: pod install
run: pod install --repo-update

- name: Inject AppID
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:' Tests.ts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/react-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -44,4 +44,4 @@ jobs:
run: yarn install

- name: Build
run: yarn
run: yarn prepare
5 changes: 4 additions & 1 deletion binding/react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ android {
repositories {
mavenCentral()
google()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}

def found = false
def defaultDir = null
Expand Down Expand Up @@ -118,5 +121,5 @@ repositories {
dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
implementation 'ai.picovoice:cheetah-android:1.1.2'
implementation 'ai.picovoice:cheetah-android:2.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
* CheetahModule Class.
*/
public class CheetahModule extends ReactContextBaseJavaModule {

private final ReactApplicationContext reactContext;
private final Map<String, Cheetah> cheetahPool = new HashMap<>();

public CheetahModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;

Cheetah.setSdk("react-native");
}

@NonNull
Expand Down
4 changes: 2 additions & 2 deletions binding/react-native/cheetah-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Pod::Spec.new do |s|
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => "11.0" }
s.platforms = { :ios => "13.0" }
s.source = { :git => "https://github.com/Picovoice/cheetah.git", :tag => "#{s.version}" }

s.source_files = "ios/*.{h,m,mm,swift}"

s.dependency "React"
s.dependency "Cheetah-iOS", '~> 1.1.0'
s.dependency "Cheetah-iOS", '~> 2.0.0'
end
7 changes: 6 additions & 1 deletion binding/react-native/ios/Cheetah.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Picovoice Inc.
// Copyright 2022-2023 Picovoice Inc.
//
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
// file accompanying this source.
Expand All @@ -15,6 +15,11 @@ import Cheetah
class PvCheetah: NSObject {
private var cheetahPool: [String: Cheetah] = [:]

override init() {
super.init()
Cheetah.setSdk(sdk: "react-native")
}

@objc(create:modelPath:endpointDuration:enableAutomaticPunctuation:resolver:rejecter:)
func create(
accessKey: String,
Expand Down
2 changes: 1 addition & 1 deletion binding/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@picovoice/cheetah-react-native",
"version": "1.1.1",
"version": "2.0.0",
"description": "Picovoice Cheetah React Native binding",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
1 change: 0 additions & 1 deletion binding/react-native/test-app/CheetahTestApp/.ruby-version

This file was deleted.

6 changes: 0 additions & 6 deletions binding/react-native/test-app/CheetahTestApp/Gemfile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ buildscript {
repositories {
google()
mavenCentral()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
Expand All @@ -36,6 +39,9 @@ allprojects {

allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}
maven {
url("$rootDir/../node_modules/detox/Detox-android")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
"$(inherited)",
);
INFOPLIST_FILE = CheetahTestAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -466,7 +466,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
INFOPLIST_FILE = CheetahTestAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -584,7 +584,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
Expand Down Expand Up @@ -649,7 +649,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
Expand Down
3 changes: 2 additions & 1 deletion binding/react-native/test-app/CheetahTestApp/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, min_ios_version_supported
platform :ios, '13.0'
prepare_react_native_project!

flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
Expand All @@ -14,6 +14,7 @@ end

target 'CheetahTestApp' do
config = use_native_modules!
pod 'Cheetah-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/cheetah/v2.0-ios/binding/ios/Cheetah-iOS.podspec'

# Flags change depending on the env values.
flags = get_default_flags()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jun 29 23:02:09 PDT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion demo/react-native/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default class App extends Component<Props, State> {
handleError(err: any) {
let errorMessage: string;
if (err instanceof CheetahErrors.CheetahInvalidArgumentError) {
errorMessage = `${err.message}\nPlease make sure accessKey ${this._accessKey} is a valid access key.`;
errorMessage = `${err.message}`;
} else if (err instanceof CheetahErrors.CheetahActivationError) {
errorMessage = 'AccessKey activation error';
} else if (err instanceof CheetahErrors.CheetahActivationLimitError) {
Expand Down
6 changes: 6 additions & 0 deletions demo/react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ buildscript {
repositories {
google()
jcenter()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.3")
Expand All @@ -32,6 +35,9 @@ allprojects {

google()
jcenter()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302'
}
maven { url 'https://www.jitpack.io' }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Nov 02 11:32:43 PDT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
8 changes: 4 additions & 4 deletions demo/react-native/ios/CheetahDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
DEVELOPMENT_TEAM = 65723695GD;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = CheetahDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
Expand All @@ -320,7 +320,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 65723695GD;
INFOPLIST_FILE = CheetahDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -382,7 +382,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
LIBRARY_SEARCH_PATHS = (
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
Expand Down Expand Up @@ -434,7 +434,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
LIBRARY_SEARCH_PATHS = (
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
Expand Down
3 changes: 2 additions & 1 deletion demo/react-native/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'
platform :ios, '13.0'

target 'CheetahDemo' do
config = use_native_modules!
pod 'Cheetah-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/cheetah/v2.0-ios/binding/ios/Cheetah-iOS.podspec'
use_react_native!(:path => config["reactNativePath"])
end
Loading

0 comments on commit 4c137f4

Please sign in to comment.