Use xcframework for Flutter iOS plugin. (#1547)

This commit is contained in:
Fangjun Kuang
2024-11-16 16:42:02 +08:00
committed by GitHub
parent e993c08538
commit 9a48012648
24 changed files with 216 additions and 49 deletions

View File

@@ -25,7 +25,7 @@ String? _path;
// https://github.com/flutter/codelabs/blob/main/ffigen_codelab/step_05/lib/ffigen_app.dart
// https://api.flutter.dev/flutter/dart-io/Platform-class.html
final DynamicLibrary _dylib = () {
if (Platform.isMacOS || Platform.isIOS) {
if (Platform.isMacOS) {
if (_path == null) {
return DynamicLibrary.open('libsherpa-onnx-c-api.dylib');
} else {
@@ -33,6 +33,14 @@ final DynamicLibrary _dylib = () {
}
}
if (Platform.isIOS) {
if (_path == null) {
return DynamicLibrary.open('sherpa_onnx.framework/sherpa_onnx');
} else {
return DynamicLibrary.open('$_path/sherpa_onnx.framework/sherpa_onnx');
}
}
if (Platform.isAndroid || Platform.isLinux) {
if (_path == null) {
return DynamicLibrary.open('libsherpa-onnx-c-api.so');

View File

@@ -17,7 +17,7 @@ topics:
- voice-activity-detection
# remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
version: 1.10.30
version: 1.10.31
homepage: https://github.com/k2-fsa/sherpa-onnx
@@ -30,23 +30,23 @@ dependencies:
flutter:
sdk: flutter
sherpa_onnx_android: ^1.10.30
sherpa_onnx_android: ^1.10.31
# sherpa_onnx_android:
# path: ../sherpa_onnx_android
sherpa_onnx_macos: ^1.10.30
sherpa_onnx_macos: ^1.10.31
# sherpa_onnx_macos:
# path: ../sherpa_onnx_macos
sherpa_onnx_linux: ^1.10.30
sherpa_onnx_linux: ^1.10.31
# sherpa_onnx_linux:
# path: ../sherpa_onnx_linux
sherpa_onnx_windows: ^1.10.30
sherpa_onnx_windows: ^1.10.31
# sherpa_onnx_windows:
# path: ../sherpa_onnx_windows
sherpa_onnx_ios: ^1.10.30
sherpa_onnx_ios: ^1.10.31
# sherpa_onnx_ios:
# path: ../sherpa_onnx_ios

View File

@@ -7,7 +7,7 @@
# https://groups.google.com/g/dart-ffi/c/nUATMBy7r0c
Pod::Spec.new do |s|
s.name = 'sherpa_onnx_ios'
s.version = '1.10.30'
s.version = '1.10.31'
s.summary = 'A new Flutter FFI plugin project.'
s.description = <<-DESC
A new Flutter FFI plugin project.
@@ -23,7 +23,8 @@ A new Flutter FFI plugin project.
s.source = { :path => '.' }
s.dependency 'Flutter'
s.platform = :ios, '12.0'
s.ios.vendored_libraries = '*.dylib', '*.a'
s.preserve_paths = 'sherpa_onnx.xcframework/**/*'
s.vendored_frameworks = 'sherpa_onnx.xcframework'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = {

View File

@@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'sherpa_onnx_macos'
s.version = '1.10.30'
s.version = '1.10.31'
s.summary = 'sherpa-onnx Flutter FFI plugin project.'
s.description = <<-DESC
sherpa-onnx Flutter FFI plugin project.