Skip to content

Commit

Permalink
Remove bitcode from iOS and make available on SPM (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
albho authored Dec 4, 2024
1 parent 4ff1e27 commit 012b11b
Show file tree
Hide file tree
Showing 27 changed files with 190 additions and 454 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/ios-browserstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,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}}:'
FalconAppTestUITests/FalconAppTestUITests.swift

- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace FalconAppTest.xcworkspace
-project FalconAppTest.xcodeproj
-sdk iphoneos
-scheme FalconAppTest
-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 FalconDemo.xcworkspace
-project FalconDemo.xcodeproj
-sdk iphoneos
-scheme FalconDemo
-derivedDataPath ddp
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/ios-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,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 @@ -70,7 +64,7 @@ jobs:
- name: XCode Build
run: xcrun xcodebuild build-for-testing
-configuration Debug
-workspace FalconAppTest.xcworkspace
-project FalconAppTest.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,2 +1,5 @@
.DS_Store
.idea
.idea
.build
Package.resolved
.swiftpm
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "demo/c/pvrecorder"]
path = demo/c/pvrecorder
url = ../../Picovoice/pvrecorder.git
url = https://github.com/Picovoice/pvrecorder.git
[submodule "demo/c/dr_libs"]
path = demo/c/dr_libs
url = ../../mackron/dr_libs.git
url = https://github.com/mackron/dr_libs.git
36 changes: 36 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "Falcon-iOS",
platforms: [
.iOS(.v13)
],
products: [
.library(
name: "Falcon",
targets: ["Falcon"]
)
],
targets: [
.binaryTarget(
name: "PvFalcon",
path: "lib/ios/PvFalcon.xcframework"
),
.target(
name: "Falcon",
dependencies: ["PvFalcon"],
path: ".",
exclude: [
"binding/ios/FalconAppTest",
"demo"
],
sources: [
"binding/ios/Falcon.swift",
"binding/ios/FalconErrors.swift"
],
resources: [
.copy("lib/common/falcon_params.pv")
]
)
]
)
10 changes: 7 additions & 3 deletions binding/ios/Falcon-iOS.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'Falcon-iOS'
s.module_name = 'Falcon'
s.version = '1.0.0'
s.version = '1.0.1'
s.license = {:type => 'Apache 2.0'}
s.summary = 'iOS SDK for Picovoice\'s Falcon speaker diarization engine.'
s.description =
Expand All @@ -12,11 +12,15 @@ Pod::Spec.new do |s|
DESC
s.homepage = 'https://github.com/Picovoice/falcon/tree/main/binding/ios'
s.author = { 'Picovoice' => '[email protected]' }
s.source = { :git => "https://github.com/Picovoice/falcon.git", :tag => "Falcon-iOS-v1.0.0" }
s.source = { :git => "https://github.com/Picovoice/falcon.git", :tag => s.version.to_s }
s.ios.deployment_target = '13.0'
s.swift_version = '5.0'
s.vendored_frameworks = 'lib/ios/PvFalcon.xcframework'
s.resources = 'lib/common/falcon_params.pv'
s.resource_bundles = {
'FalconResources' => [
'lib/common/falcon_params.pv'
]
}
s.source_files = 'binding/ios/*.{swift}'
s.exclude_files = 'binding/ios/FalconTestApp/**'
end
35 changes: 29 additions & 6 deletions binding/ios/Falcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ public struct FalconSegment {

/// iOS binding for Falcon speaker diarization engine. Provides a Swift interface to the Falcon library.
public class Falcon {

#if SWIFT_PACKAGE

static let resourceBundle = Bundle.module

#else

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

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

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

return resourceBundle
}()

#endif

private static let supportedAudioTypes: Set = [
"3gp",
"flac",
Expand Down Expand Up @@ -75,13 +101,10 @@ public class Falcon {
}

var modelPathArg = modelPath

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

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

Expand Down
Loading

0 comments on commit 012b11b

Please sign in to comment.