Skip to content

Commit

Permalink
Remove bitcode from iOS and make available on SPM (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
albho authored Nov 28, 2024
1 parent bfd2d3a commit 0f5edd1
Show file tree
Hide file tree
Showing 35 changed files with 357 additions and 1,322 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/ios-browserstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,20 @@ jobs:
- run:
pip3 install requests

- name: Install Cocoapods
run: gem install cocoapods

- name: Make build dir
run: mkdir ddp

- name: Copy test_resources
run: ./copy_test_resources.sh

- name: Run Cocoapods
run: pod install

- name: Inject AccessKey
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:'
RhinoAppTestUITests/BaseTest.swift

- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace RhinoAppTest.xcworkspace
-project RhinoAppTest.xcodeproj
-sdk iphoneos
-scheme RhinoAppTest
-derivedDataPath ddp
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/ios-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Node.js LTS
uses: actions/setup-node@v3
with:
node-version: lts/*

- name: Install Cocoapods
run: gem install cocoapods

- name: Make build dir
run: mkdir ddp

- name: Run Cocoapods
run: pod install

- name: Build English
run: xcrun xcodebuild build
-configuration Debug
-workspace RhinoDemo.xcworkspace
-project RhinoDemo.xcodeproj
-sdk iphoneos
-scheme _enDemo
-derivedDataPath ddp
Expand All @@ -50,8 +36,8 @@ jobs:
- name: Build Other Language
run: xcrun xcodebuild build
-configuration Debug
-workspace RhinoDemo.xcworkspace
-project RhinoDemo.xcodeproj
-sdk iphoneos
-scheme frDemo
-derivedDataPath ddp
CODE_SIGNING_ALLOWED=NO
CODE_SIGNING_ALLOWED=NO
8 changes: 1 addition & 7 deletions .github/workflows/ios-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@ jobs:
- run:
pip3 install requests

- name: Install Cocoapods
run: gem install cocoapods

- name: Make build dir
run: mkdir ddp

- name: Copy test_resources
run: ./copy_test_resources.sh

- name: Run Cocoapods
run: pod install

- name: Inject AccessKey
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:'
PerformanceTest/PerformanceTest.swift
Expand All @@ -72,7 +66,7 @@ jobs:
- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace RhinoAppTest.xcworkspace
-project RhinoAppTest.xcodeproj
-sdk iphoneos
-scheme PerformanceTest
-derivedDataPath ddp
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
__pycache__
build
demo/c/cmake-build-debug
.build
Package.resolved
.swiftpm
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "binding/unity/VoiceProcessor"]
path = binding/unity/VoiceProcessor
url = ../unity-voice-processor.git
url = https://github.com/Picovoice/unity-voice-processor.git
[submodule "demo/c/dr_libs"]
path = demo/c/dr_libs
url = ../../mackron/dr_libs.git
url = https://github.com/mackron/dr_libs.git
[submodule "demo/c/pvrecorder"]
path = demo/c/pvrecorder
url = ../pvrecorder.git
url = https://github.com/Picovoice/pvrecorder.git
49 changes: 49 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "Rhino-iOS",
platforms: [
.iOS(.v13)
],
products: [
.library(
name: "Rhino",
targets: ["Rhino"]
)
],
dependencies: [
.package(
url: "https://github.com/Picovoice/ios-voice-processor.git",
.upToNextMajor(from: "1.2.0")
)
],
targets: [
.binaryTarget(
name: "PvRhino",
path: "lib/ios/PvRhino.xcframework"
),
.target(
name: "Rhino",
dependencies: [
"PvRhino",
.product(name: "ios_voice_processor", package: "ios-voice-processor")
],
path: ".",
exclude: [
"binding/ios/RhinoAppTest",
"binding/flutter",
"binding/react-native",
"binding/unity",
"demo"
],
sources: [
"binding/ios/Rhino.swift",
"binding/ios/RhinoErrors.swift",
"binding/ios/RhinoManager.swift"
],
resources: [
.copy("lib/common/rhino_params.pv")
]
)
]
)
10 changes: 8 additions & 2 deletions binding/ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ Rhino is:
## Installation

<!-- markdown-link-check-disable -->
The Rhino iOS binding is available via [CocoaPods](https://cocoapods.org/pods/Rhino-iOS). To import it into your iOS project, add the following line to your Podfile and run `pod install`:
The Rhino iOS binding is available via [Swift Package Manager](https://www.swift.org/documentation/package-manager/) or [CocoaPods](https://cocoapods.org/pods/Rhino-iOS).
<!-- markdown-link-check-enable -->

To import the package using SPM, open up your project's Package Dependencies in XCode and add:
```
https://github.com/Picovoice/rhino.git
```
To import it into your iOS project using CocoaPods, add the following line to your Podfile:

```ruby
pod 'Rhino-iOS'
```
Expand Down Expand Up @@ -182,7 +188,7 @@ In order to run inference on non-English contexts you need to use the correspond

## Running Unit Tests

Copy your `AccessKey` into the `accessKey` variable in [`RhinoAppTestUITests.swift`](RhinoAppTest/RhinoAppTestUITests/RhinoAppTestUITests.swift). Open `RhinoAppTest.xcworkspace` with XCode and run the tests with `Product > Test`.
Copy your `AccessKey` into the `accessKey` variable in [`RhinoAppTestUITests.swift`](RhinoAppTest/RhinoAppTestUITests/RhinoAppTestUITests.swift). Open [`RhinoAppTest.xcodeproj`](RhinoAppTest/RhinoAppTest.xcodeproj) with XCode and run the tests with `Product > Test`.

## Demo App

Expand Down
6 changes: 3 additions & 3 deletions binding/ios/Rhino-iOS.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'Rhino-iOS'
s.module_name = 'Rhino'
s.version = '3.0.1'
s.version = '3.0.2'
s.license = {:type => 'Apache 2.0'}
s.summary = 'iOS SDK for Picovoice\'s Rhino Speech-to-Intent engine'
s.description =
Expand All @@ -24,7 +24,7 @@ Pod::Spec.new do |s|
DESC
s.homepage = 'https://github.com/Picovoice/rhino/tree/master/binding/ios'
s.author = { 'Picovoice' => '[email protected]' }
s.source = { :git => "https://github.com/Picovoice/rhino.git", :tag => "Rhino-iOS-v3.0.1" }
s.source = { :git => "https://github.com/Picovoice/rhino.git", :tag => s.version.to_s }
s.ios.deployment_target = '13.0'
s.swift_version = '5.0'
s.vendored_frameworks = 'lib/ios/PvRhino.xcframework'
Expand All @@ -36,5 +36,5 @@ Pod::Spec.new do |s|
s.source_files = 'binding/ios/*.{swift}'
s.exclude_files = 'binding/ios/RhinoAppTest/**'

s.dependency 'ios-voice-processor', '~> 1.1.0'
s.dependency 'ios-voice-processor', '~> 1.2.0'
end
12 changes: 11 additions & 1 deletion binding/ios/Rhino.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//
// Copyright 2021-2023 Picovoice Inc.
// Copyright 2021-2024 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.
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
//

import Foundation

import PvRhino

public struct Inference {
Expand All @@ -24,6 +26,12 @@ public struct Inference {
/// Low-level iOS binding for Rhino wake word engine. Provides a Swift interface to the Rhino library.
public class Rhino {

#if SWIFT_PACKAGE

static let resourceBundle = Bundle.module

#else

static let resourceBundle: Bundle = {
let myBundle = Bundle(for: Rhino.self)

Expand All @@ -41,6 +49,8 @@ public class Rhino {
return resourceBundle
}()

#endif

private var handle: OpaquePointer?
public static let frameLength = UInt32(pv_rhino_frame_length())
public static let sampleRate = UInt32(pv_sample_rate())
Expand Down
14 changes: 0 additions & 14 deletions binding/ios/RhinoAppTest/Podfile

This file was deleted.

20 changes: 0 additions & 20 deletions binding/ios/RhinoAppTest/Podfile.lock

This file was deleted.

Loading

0 comments on commit 0f5edd1

Please sign in to comment.