Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/ios.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: ios

on:
push:
branches:
- master
- ios-spm
paths:
- '.github/workflows/ios.yaml'
- 'ios-swiftui/**'
- 'swift-api-examples/**'
- 'Package.swift'

workflow_dispatch:

concurrency:
group: ios-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
sherpa-onnx:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
Comment thread
coderabbitai[bot] marked this conversation as resolved.
persist-credentials: false

- name: Build SherpaOnnx
shell: bash
run: |
set -euo pipefail
cd ios-swiftui/SherpaOnnx
xcodebuild -project SherpaOnnx.xcodeproj \
-scheme SherpaOnnx \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build | tail -20
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment on lines +36 to +41

sherpa-onnx-2pass:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Build SherpaOnnx2Pass
shell: bash
run: |
set -euo pipefail
cd ios-swiftui/SherpaOnnx2Pass
xcodebuild -project SherpaOnnx2Pass.xcodeproj \
-scheme SherpaOnnx2Pass \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build | tail -20

sherpa-onnx-lang-id:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Build SherpaOnnxLangID
shell: bash
run: |
set -euo pipefail
cd ios-swiftui/SherpaOnnxLangID
xcodebuild -project SherpaOnnxLangID.xcodeproj \
-scheme SherpaOnnxLangID \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build | tail -20

sherpa-onnx-subtitle:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Build SherpaOnnxSubtitle
shell: bash
run: |
set -euo pipefail
cd ios-swiftui/SherpaOnnxSubtitle
xcodebuild -project SherpaOnnxSubtitle.xcodeproj \
-scheme SherpaOnnxSubtitle \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build | tail -20

sherpa-onnx-tts:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Build SherpaOnnxTts
shell: bash
run: |
set -euo pipefail
cd ios-swiftui/SherpaOnnxTts
xcodebuild -project SherpaOnnxTts.xcodeproj \
-scheme SherpaOnnxTts \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build | tail -20
5 changes: 5 additions & 0 deletions build-swift-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ xcodebuild -create-xcframework \
-headers install/include/sherpa-onnx/c-api \
-output sherpa-onnx.xcframework

# Remove the module map from the install directory to prevent swiftc from
# auto-discovering it. The module map is only needed inside the xcframework
# (used by SPM). For direct swiftc builds, the bridging header is used instead.
rm -fv ./install/include/sherpa-onnx/c-api/module.modulemap

SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)

rm -f sherpa-onnx-${SHERPA_ONNX_VERSION}-macos.xcframework.zip
Expand Down
1 change: 1 addition & 0 deletions ios-swiftui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,4 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
swiftpm
58 changes: 28 additions & 30 deletions ios-swiftui/SherpaOnnx/SherpaOnnx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
C924F33F29DDAC0D00A440A5 /* SherpaOnnxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C924F33E29DDAC0D00A440A5 /* SherpaOnnxTests.swift */; };
C924F34929DDAC0D00A440A5 /* SherpaOnnxUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C924F34829DDAC0D00A440A5 /* SherpaOnnxUITests.swift */; };
C924F34B29DDAC0D00A440A5 /* SherpaOnnxUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C924F34A29DDAC0D00A440A5 /* SherpaOnnxUITestsLaunchTests.swift */; };
C924F35929DDACED00A440A5 /* SherpaOnnx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C924F35829DDACED00A440A5 /* SherpaOnnx.swift */; };
C924F35C29DDAE4000A440A5 /* sherpa-onnx.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C924F35B29DDAE4000A440A5 /* sherpa-onnx.xcframework */; };
C924F35E29DDAE8200A440A5 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = C924F35D29DDAE8200A440A5 /* Model.swift */; };
C924F36029DDB05D00A440A5 /* onnxruntime.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C924F35F29DDB05D00A440A5 /* onnxruntime.xcframework */; };
C924F36229DDB15D00A440A5 /* Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C924F36129DDB15D00A440A5 /* Extension.swift */; };
C924F36429DDB1D500A440A5 /* SherpaOnnxViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C924F36329DDB1D500A440A5 /* SherpaOnnxViewModel.swift */; };
C9SP000000000001 /* sherpa-onnx in Frameworks */ = {isa = PBXBuildFile; productRef = C9SP000000000002 /* sherpa-onnx */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -50,11 +48,7 @@
C924F34429DDAC0D00A440A5 /* SherpaOnnxUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SherpaOnnxUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C924F34829DDAC0D00A440A5 /* SherpaOnnxUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxUITests.swift; sourceTree = "<group>"; };
C924F34A29DDAC0D00A440A5 /* SherpaOnnxUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxUITestsLaunchTests.swift; sourceTree = "<group>"; };
C924F35729DDACED00A440A5 /* SherpaOnnx-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "SherpaOnnx-Bridging-Header.h"; path = "../../../swift-api-examples/SherpaOnnx-Bridging-Header.h"; sourceTree = "<group>"; };
C924F35829DDACED00A440A5 /* SherpaOnnx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SherpaOnnx.swift; path = "../../../swift-api-examples/SherpaOnnx.swift"; sourceTree = "<group>"; };
C924F35B29DDAE4000A440A5 /* sherpa-onnx.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = "sherpa-onnx.xcframework"; path = "../../build-ios/sherpa-onnx.xcframework"; sourceTree = "<group>"; };
C924F35D29DDAE8200A440A5 /* Model.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
C924F35F29DDB05D00A440A5 /* onnxruntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = onnxruntime.xcframework; path = "../../build-ios/ios-onnxruntime/onnxruntime.xcframework"; sourceTree = "<group>"; };
C924F36129DDB15D00A440A5 /* Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Extension.swift; sourceTree = "<group>"; };
C924F36329DDB1D500A440A5 /* SherpaOnnxViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SherpaOnnxViewModel.swift; sourceTree = "<group>"; };
DEFC34EE2BBA8AD100E174E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -65,8 +59,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C924F36029DDB05D00A440A5 /* onnxruntime.xcframework in Frameworks */,
C924F35C29DDAE4000A440A5 /* sherpa-onnx.xcframework in Frameworks */,
C9SP000000000001 /* sherpa-onnx in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -94,7 +87,6 @@
C924F33D29DDAC0D00A440A5 /* SherpaOnnxTests */,
C924F34729DDAC0D00A440A5 /* SherpaOnnxUITests */,
C924F32B29DDAC0B00A440A5 /* Products */,
C924F35A29DDAE3F00A440A5 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -115,8 +107,6 @@
C924F36329DDB1D500A440A5 /* SherpaOnnxViewModel.swift */,
C924F36129DDB15D00A440A5 /* Extension.swift */,
C924F35D29DDAE8200A440A5 /* Model.swift */,
C924F35729DDACED00A440A5 /* SherpaOnnx-Bridging-Header.h */,
C924F35829DDACED00A440A5 /* SherpaOnnx.swift */,
C924F32D29DDAC0B00A440A5 /* SherpaOnnxApp.swift */,
C924F32F29DDAC0B00A440A5 /* ContentView.swift */,
C924F33129DDAC0D00A440A5 /* Assets.xcassets */,
Expand Down Expand Up @@ -150,15 +140,6 @@
path = SherpaOnnxUITests;
sourceTree = "<group>";
};
C924F35A29DDAE3F00A440A5 /* Frameworks */ = {
isa = PBXGroup;
children = (
C924F35F29DDB05D00A440A5 /* onnxruntime.xcframework */,
C924F35B29DDAE4000A440A5 /* sherpa-onnx.xcframework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -167,14 +148,16 @@
buildConfigurationList = C924F34E29DDAC0D00A440A5 /* Build configuration list for PBXNativeTarget "SherpaOnnx" */;
buildPhases = (
C924F32629DDAC0B00A440A5 /* Sources */,
C924F32729DDAC0B00A440A5 /* Frameworks */,
C924F32829DDAC0B00A440A5 /* Resources */,
);
Comment on lines 148 to 152
buildRules = (
);
dependencies = (
);
name = SherpaOnnx;
packageProductDependencies = (
C9SP000000000002 /* sherpa-onnx */,
);
productName = SherpaOnnx;
productReference = C924F32A29DDAC0B00A440A5 /* SherpaOnnx.app */;
productType = "com.apple.product-type.application";
Expand All @@ -184,7 +167,6 @@
buildConfigurationList = C924F35129DDAC0D00A440A5 /* Build configuration list for PBXNativeTarget "SherpaOnnxTests" */;
buildPhases = (
C924F33629DDAC0D00A440A5 /* Sources */,
C924F33729DDAC0D00A440A5 /* Frameworks */,
C924F33829DDAC0D00A440A5 /* Resources */,
);
buildRules = (
Expand All @@ -202,7 +184,6 @@
buildConfigurationList = C924F35429DDAC0D00A440A5 /* Build configuration list for PBXNativeTarget "SherpaOnnxUITests" */;
buildPhases = (
C924F34029DDAC0D00A440A5 /* Sources */,
C924F34129DDAC0D00A440A5 /* Frameworks */,
C924F34229DDAC0D00A440A5 /* Resources */,
);
buildRules = (
Expand Down Expand Up @@ -247,6 +228,9 @@
Base,
);
mainGroup = C924F32129DDAC0B00A440A5;
packageReferences = (
C9SP000000000003 /* XCRemoteSwiftPackageReference "sherpa-onnx" */,
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
productRefGroup = C924F32B29DDAC0B00A440A5 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -291,7 +275,6 @@
files = (
C924F36229DDB15D00A440A5 /* Extension.swift in Sources */,
C924F33029DDAC0B00A440A5 /* ContentView.swift in Sources */,
C924F35929DDACED00A440A5 /* SherpaOnnx.swift in Sources */,
C924F32E29DDAC0B00A440A5 /* SherpaOnnxApp.swift in Sources */,
C924F36429DDB1D500A440A5 /* SherpaOnnxViewModel.swift in Sources */,
C924F35E29DDAE8200A440A5 /* Model.swift in Sources */,
Expand Down Expand Up @@ -468,11 +451,9 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = "-lc++";
PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnx";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down Expand Up @@ -501,11 +482,9 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = "-lc++";
PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnx";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down Expand Up @@ -625,4 +604,23 @@
/* End XCConfigurationList section */
};
rootObject = C924F32229DDAC0B00A440A5 /* Project object */;
}

/* Begin XCRemoteSwiftPackageReference section */
C9SP000000000003 /* XCRemoteSwiftPackageReference "sherpa-onnx" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/k2-fsa/sherpa-onnx";
requirement = {
kind = branch;
branch = master;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
C9SP000000000002 /* sherpa-onnx */ = {
isa = XCSwiftPackageProductDependency;
package = C9SP000000000003 /* XCRemoteSwiftPackageReference "sherpa-onnx" */;
productName = "sherpa-onnx";
};
/* End XCSwiftPackageProductDependency section */
}
1 change: 1 addition & 0 deletions ios-swiftui/SherpaOnnx/SherpaOnnx/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by fangjun on 2023/4/5.
//

import SherpaOnnx
import SwiftUI

struct ContentView: View {
Expand Down
1 change: 1 addition & 0 deletions ios-swiftui/SherpaOnnx/SherpaOnnx/Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by knight on 2023/4/5.
//

import SherpaOnnx
import AVFoundation

extension AudioBuffer {
Expand Down
1 change: 1 addition & 0 deletions ios-swiftui/SherpaOnnx/SherpaOnnx/Model.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import SherpaOnnx
import Foundation

func getResource(_ forResource: String, _ ofType: String) -> String {
Expand Down
1 change: 1 addition & 0 deletions ios-swiftui/SherpaOnnx/SherpaOnnx/SherpaOnnxApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by fangjun on 2023/4/5.
//

import SherpaOnnx
import SwiftUI

@main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by knight on 2023/4/5.
//

import SherpaOnnx
import AVFoundation
import Foundation

Expand Down
Loading
Loading