Skip to content

Commit

Permalink
Remove bitcode from iOS and make available on SPM (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
albho authored Dec 4, 2024
1 parent f75d286 commit 7adacd8
Show file tree
Hide file tree
Showing 29 changed files with 318 additions and 484 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ios-browserstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@ jobs:
- run:
pip3 install requests

- name: Install Cocoapods
run: gem install cocoapods

- name: Make build dir
run: mkdir ddp

- name: Run Cocoapods
run: pod install
- name: Copy test_resources
run: ./copy_test_resources.sh

- name: Inject AccessKey
run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:'
Expand All @@ -52,7 +49,7 @@ jobs:
- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace OctopusAppTest.xcworkspace
-project OctopusAppTest.xcodeproj
-sdk iphoneos
-scheme OctopusAppTest
-derivedDataPath ddp
Expand Down
16 changes: 1 addition & 15 deletions .github/workflows/ios-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,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
run: xcrun xcodebuild build
-configuration Debug
-workspace OctopusDemo.xcworkspace
-project OctopusDemo.xcodeproj
-sdk iphoneos
-scheme OctopusDemo
-derivedDataPath ddp
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/ios-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@ jobs:
- run:
pip3 install requests

- name: Install Cocoapods
run: gem install cocoapods

- name: Make build dir
run: mkdir ddp

- name: Run Cocoapods
run: pod install
- name: Copy test_resources
run: ./copy_test_resources.sh

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

Expand All @@ -73,7 +70,7 @@ jobs:
- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace OctopusAppTest.xcworkspace
-project OctopusAppTest.xcodeproj
-sdk iphoneos
-scheme PerformanceTest
-derivedDataPath ddp
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.idea
multiple_keywords.idx
.DS_Store
.DS_Store
.build
Package.resolved
.swiftpm
37 changes: 37 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "Octopus-iOS",
platforms: [
.iOS(.v13)
],
products: [
.library(
name: "Octopus",
targets: ["Octopus"]
)
],
targets: [
.binaryTarget(
name: "PvOctopus",
path: "lib/ios/PvOctopus.xcframework"
),
.target(
name: "Octopus",
dependencies: ["PvOctopus"],
path: ".",
exclude: [
"binding/ios/OctopusAppTest",
"demo"
],
sources: [
"binding/ios/Octopus.swift",
"binding/ios/OctopusErrors.swift",
"binding/ios/OctopusMetadata.swift"
],
resources: [
.copy("lib/common/param/octopus_params.pv")
]
)
]
)
10 changes: 7 additions & 3 deletions binding/ios/Octopus-iOS.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'Octopus-iOS'
s.module_name = 'Octopus'
s.version = '2.0.0'
s.version = '2.0.1'
s.license = {:type => 'Apache 2.0'}
s.summary = 'iOS binding for Picovoice\'s Octopus Speech-to-Index engine'
s.description =
Expand All @@ -12,11 +12,15 @@ Pod::Spec.new do |s|
DESC
s.homepage = 'https://github.com/Picovoice/octopus/tree/master/binding/ios'
s.author = { 'Picovoice' => '[email protected]' }
s.source = { :git => "https://github.com/Picovoice/octopus.git", :tag => "Octopus-iOS-v2.0.0" }
s.source = { :git => "https://github.com/Picovoice/octopus.git", :tag => s.version.to_s }
s.ios.deployment_target = '13.0'
s.swift_version = '5.0'
s.vendored_frameworks = 'lib/ios/PvOctopus.xcframework'
s.resources = 'lib/common/param/octopus_params.pv'
s.resource_bundles = {
'OctopusResources' => [
'lib/common/param/octopus_params.pv'
]
}
s.source_files = 'binding/ios/*.{swift}'
s.exclude_files = 'binding/ios/OctopusTestApp/**'
end
33 changes: 28 additions & 5 deletions binding/ios/Octopus.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// 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
Expand All @@ -25,6 +25,31 @@ public struct OctopusMatch {
/// iOS binding for Octopus Speech-to-Index engine. It transforms audio into searchable metadata.
public class Octopus {

#if SWIFT_PACKAGE

static let resourceBundle = Bundle.module

#else

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

guard let resourceBundleURL = myBundle.url(
forResource: "OctopusResources", withExtension: "bundle")
else {
fatalError("OctopusResources.bundle not found")
}

guard let resourceBundle = Bundle(url: resourceBundleURL)
else {
fatalError("Could not open OctopusResources.bundle")
}

return resourceBundle
}()

#endif

/// Required audio sample rate for PCM data
public static let pcmDataSampleRate = Int(pv_sample_rate())

Expand All @@ -50,11 +75,9 @@ public class Octopus {
var modelPathArg = modelPath

if modelPath == nil {
let bundle = Bundle(for: type(of: self))

modelPathArg = bundle.path(forResource: "octopus_params", ofType: "pv")
modelPathArg = Octopus.resourceBundle.path(forResource: "octopus_params", ofType: "pv")
if modelPathArg == nil {
throw OctopusIOError("Could not retrieve default model from app bundle")
throw OctopusIOError("Could not find default model file in app bundle.")
}
}

Expand Down
5 changes: 4 additions & 1 deletion binding/ios/OctopusAppTest/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ build/*
*.pbxuser
xcuserdata
Pods
ddp
ddp

OctopusAppTestUITests/test_resources/*
!OctopusAppTestUITests/test_resources/.gitkeep
Loading

0 comments on commit 7adacd8

Please sign in to comment.