正在显示
34 个修改的文件
包含
2669 行增加
和
23 行删除
| @@ -21,3 +21,15 @@ run-zh.sh | @@ -21,3 +21,15 @@ run-zh.sh | ||
| 21 | decode-file-c-api | 21 | decode-file-c-api |
| 22 | run-decode-file-c-api.sh | 22 | run-decode-file-c-api.sh |
| 23 | sherpa-onnx-ffmpeg | 23 | sherpa-onnx-ffmpeg |
| 24 | +build-ios | ||
| 25 | +build-swift-macos | ||
| 26 | +aa.sh | ||
| 27 | +client-2.sh | ||
| 28 | +ffmpeg-examples/run-3.sh | ||
| 29 | +python-api-examples/decode-file-multiple-bak-2.py | ||
| 30 | +run-en-zipformer-microphone* | ||
| 31 | +run-websocket-server* | ||
| 32 | +decode-file | ||
| 33 | +*.dylib | ||
| 34 | +tokens.txt | ||
| 35 | +*.onnx |
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<project version="4"> | ||
| 3 | - <component name="deploymentTargetDropDown"> | ||
| 4 | - <runningDeviceTargetSelectedWithDropDown> | ||
| 5 | - <Target> | ||
| 6 | - <type value="RUNNING_DEVICE_TARGET" /> | ||
| 7 | - <deviceKey> | ||
| 8 | - <Key> | ||
| 9 | - <type value="SERIAL_NUMBER" /> | ||
| 10 | - <value value="50e6c115" /> | ||
| 11 | - </Key> | ||
| 12 | - </deviceKey> | ||
| 13 | - </Target> | ||
| 14 | - </runningDeviceTargetSelectedWithDropDown> | ||
| 15 | - <timeTargetWasSelectedWithDropDown value="2023-02-23T09:59:16.822185Z" /> | ||
| 16 | - </component> | ||
| 17 | -</project> |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <project version="4"> | 2 | <project version="4"> |
| 3 | + <component name="GradleMigrationSettings" migrationVersion="1" /> | ||
| 3 | <component name="GradleSettings"> | 4 | <component name="GradleSettings"> |
| 4 | <option name="linkedExternalProjectsSettings"> | 5 | <option name="linkedExternalProjectsSettings"> |
| 5 | <GradleProjectSettings> | 6 | <GradleProjectSettings> |
build-ios.sh
0 → 100755
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +set -e | ||
| 4 | + | ||
| 5 | +dir=build-ios | ||
| 6 | +mkdir -p $dir | ||
| 7 | +cd $dir | ||
| 8 | + | ||
| 9 | +if [ ! -f ios-onnxruntime/onnxruntime.xcframework/ios-arm64/onnxruntime.a ]; then | ||
| 10 | + GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/ios-onnxruntime | ||
| 11 | + pushd ios-onnxruntime | ||
| 12 | + git lfs pull --include onnxruntime.xcframework/ios-arm64/onnxruntime.a | ||
| 13 | + git lfs pull --include onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.a | ||
| 14 | + popd | ||
| 15 | +fi | ||
| 16 | + | ||
| 17 | +# check filesize | ||
| 18 | +filesize=$(ls -l ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64/onnxruntime.a | tr -s " " " " | cut -d " " -f 5) | ||
| 19 | +if (( $filesize < 1000 )); then | ||
| 20 | + ls -lh ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64/onnxruntime.a | ||
| 21 | + echo "Please use: git lfs pull to download ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64/onnxruntime.a" | ||
| 22 | + exit 1 | ||
| 23 | +fi | ||
| 24 | + | ||
| 25 | +filesize=$(ls -l ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.a | tr -s " " " " | cut -d " " -f 5) | ||
| 26 | +if (( $filesize < 1000 )); then | ||
| 27 | + ls -lh ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.a | ||
| 28 | + echo "Please use: git lfs pull to download ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.a" | ||
| 29 | + exit 1 | ||
| 30 | +fi | ||
| 31 | + | ||
| 32 | +# First, for simulator | ||
| 33 | +echo "Building for simulator (x86_64)" | ||
| 34 | + | ||
| 35 | +export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator | ||
| 36 | +export SHERPA_ONNXRUNTIME_INCLUDE_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/Headers | ||
| 37 | + | ||
| 38 | +echo "SHERPA_ONNXRUNTIME_LIB_DIR: $SHERPA_ONNXRUNTIME_LIB_DIR" | ||
| 39 | +echo "SHERPA_ONNXRUNTIME_INCLUDE_DIR $SHERPA_ONNXRUNTIME_INCLUDE_DIR" | ||
| 40 | + | ||
| 41 | +# Note: We use -DENABLE_ARC=1 here to fix the linking error: | ||
| 42 | +# | ||
| 43 | +# The symbol _NSLog is not defined | ||
| 44 | +# | ||
| 45 | + | ||
| 46 | +cmake \ | ||
| 47 | + -S .. \ | ||
| 48 | + -DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \ | ||
| 49 | + -DPLATFORM=SIMULATOR64 \ | ||
| 50 | + -DENABLE_BITCODE=0 \ | ||
| 51 | + -DENABLE_ARC=1 \ | ||
| 52 | + -DENABLE_VISIBILITY=0 \ | ||
| 53 | + -DCMAKE_BUILD_TYPE=Release \ | ||
| 54 | + -DBUILD_SHARED_LIBS=OFF \ | ||
| 55 | + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| 56 | + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| 57 | + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| 58 | + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 59 | + -DSHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 60 | + -DSHERPA_ONNX_ENABLE_C_API=ON \ | ||
| 61 | + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ | ||
| 62 | + -DDEPLOYMENT_TARGET=13.0 \ | ||
| 63 | + -B build/simulator_x86_64 | ||
| 64 | + | ||
| 65 | +cmake --build build/simulator_x86_64 -j 4 --verbose | ||
| 66 | + | ||
| 67 | +echo "Building for simulator (arm64)" | ||
| 68 | + | ||
| 69 | +cmake \ | ||
| 70 | + -S .. \ | ||
| 71 | + -DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \ | ||
| 72 | + -DPLATFORM=SIMULATORARM64 \ | ||
| 73 | + -DENABLE_BITCODE=0 \ | ||
| 74 | + -DENABLE_ARC=1 \ | ||
| 75 | + -DENABLE_VISIBILITY=0 \ | ||
| 76 | + -DCMAKE_BUILD_TYPE=Release \ | ||
| 77 | + -DCMAKE_INSTALL_PREFIX=./install \ | ||
| 78 | + -DBUILD_SHARED_LIBS=OFF \ | ||
| 79 | + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| 80 | + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| 81 | + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| 82 | + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 83 | + -DSHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 84 | + -DSHERPA_ONNX_ENABLE_C_API=ON \ | ||
| 85 | + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ | ||
| 86 | + -DDEPLOYMENT_TARGET=13.0 \ | ||
| 87 | + -B build/simulator_arm64 | ||
| 88 | + | ||
| 89 | +cmake --build build/simulator_arm64 -j 4 --verbose | ||
| 90 | + | ||
| 91 | +echo "Building for arm64" | ||
| 92 | + | ||
| 93 | +export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/ios-arm64 | ||
| 94 | + | ||
| 95 | + | ||
| 96 | +cmake \ | ||
| 97 | + -S .. \ | ||
| 98 | + -DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \ | ||
| 99 | + -DPLATFORM=OS64 \ | ||
| 100 | + -DENABLE_BITCODE=0 \ | ||
| 101 | + -DENABLE_ARC=1 \ | ||
| 102 | + -DENABLE_VISIBILITY=0 \ | ||
| 103 | + -DCMAKE_INSTALL_PREFIX=./install \ | ||
| 104 | + -DCMAKE_BUILD_TYPE=Release \ | ||
| 105 | + -DBUILD_SHARED_LIBS=OFF \ | ||
| 106 | + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| 107 | + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| 108 | + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| 109 | + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 110 | + -DSHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 111 | + -DSHERPA_ONNX_ENABLE_C_API=ON \ | ||
| 112 | + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ | ||
| 113 | + -DDEPLOYMENT_TARGET=13.0 \ | ||
| 114 | + -B build/os64 | ||
| 115 | + | ||
| 116 | +cmake --build build/os64 -j 4 | ||
| 117 | +# Generate headers for sherpa-onnx.xcframework | ||
| 118 | +cmake --build build/os64 --target install | ||
| 119 | + | ||
| 120 | +echo "Generate xcframework" | ||
| 121 | + | ||
| 122 | +mkdir -p "build/simulator/lib" | ||
| 123 | +for f in libkaldi-native-fbank-core.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a; do | ||
| 124 | + lipo -create build/simulator_arm64/lib/${f} \ | ||
| 125 | + build/simulator_x86_64/lib/${f} \ | ||
| 126 | + -output build/simulator/lib/${f} | ||
| 127 | +done | ||
| 128 | + | ||
| 129 | +# Merge archive first, because the following xcodebuild create xcframework | ||
| 130 | +# cannot accept multi archive with the same architecture. | ||
| 131 | +libtool -static -o build/simulator/sherpa-onnx.a \ | ||
| 132 | + build/simulator/lib/libkaldi-native-fbank-core.a \ | ||
| 133 | + build/simulator/lib/libsherpa-onnx-c-api.a \ | ||
| 134 | + build/simulator/lib/libsherpa-onnx-core.a | ||
| 135 | + | ||
| 136 | +libtool -static -o build/os64/sherpa-onnx.a \ | ||
| 137 | + build/os64/lib/libkaldi-native-fbank-core.a \ | ||
| 138 | + build/os64/lib/libsherpa-onnx-c-api.a \ | ||
| 139 | + build/os64/lib/libsherpa-onnx-core.a | ||
| 140 | + | ||
| 141 | + | ||
| 142 | +rm -rf sherpa-onnx.xcframework | ||
| 143 | + | ||
| 144 | +xcodebuild -create-xcframework \ | ||
| 145 | + -library "build/os64/sherpa-onnx.a" \ | ||
| 146 | + -library "build/simulator/sherpa-onnx.a" \ | ||
| 147 | + -output sherpa-onnx.xcframework | ||
| 148 | + | ||
| 149 | +# Copy Headers | ||
| 150 | +mkdir -p sherpa-onnx.xcframework/Headers | ||
| 151 | +cp -av install/include/* sherpa-onnx.xcframework/Headers | ||
| 152 | + | ||
| 153 | +pushd sherpa-onnx.xcframework/ios-arm64_x86_64-simulator | ||
| 154 | +ln -s sherpa-onnx.a libsherpa-onnx.a | ||
| 155 | +popd | ||
| 156 | + | ||
| 157 | +pushd sherpa-onnx.xcframework/ios-arm64 | ||
| 158 | +ln -s sherpa-onnx.a libsherpa-onnx.a |
build-swift-macos.sh
0 → 100755
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +set -ex | ||
| 4 | + | ||
| 5 | +dir=build-swift-macos | ||
| 6 | +mkdir -p $dir | ||
| 7 | +cd $dir | ||
| 8 | + | ||
| 9 | +cmake \ | ||
| 10 | + -DCMAKE_OSX_ARCHITECTURES="x86_64" \ | ||
| 11 | + -DCMAKE_INSTALL_PREFIX=./install \ | ||
| 12 | + -DCMAKE_BUILD_TYPE=Release \ | ||
| 13 | + -DBUILD_SHARED_LIBS=OFF \ | ||
| 14 | + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| 15 | + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| 16 | + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| 17 | + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 18 | + -DSHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 19 | + -DSHERPA_ONNX_ENABLE_C_API=ON \ | ||
| 20 | + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ | ||
| 21 | + ../ | ||
| 22 | + | ||
| 23 | +make VERBOSE=1 -j4 | ||
| 24 | +make install | ||
| 25 | + | ||
| 26 | +libtool -static -o ./install/lib/libsherpa-onnx.a \ | ||
| 27 | + ./install/lib/libsherpa-onnx-c-api.a \ | ||
| 28 | + ./install/lib/libsherpa-onnx-core.a \ | ||
| 29 | + ./install/lib/libkaldi-native-fbank-core.a |
| @@ -134,7 +134,7 @@ endfunction() | @@ -134,7 +134,7 @@ endfunction() | ||
| 134 | message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") | 134 | message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") |
| 135 | message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | 135 | message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") |
| 136 | 136 | ||
| 137 | -if(ANDROID) | 137 | +if(DEFINED ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) |
| 138 | set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) | 138 | set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR}) |
| 139 | else() | 139 | else() |
| 140 | find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h | 140 | find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h |
| @@ -146,8 +146,11 @@ endif() | @@ -146,8 +146,11 @@ endif() | ||
| 146 | 146 | ||
| 147 | message(STATUS "location_onnxruntime_header_dir: ${location_onnxruntime_header_dir}") | 147 | message(STATUS "location_onnxruntime_header_dir: ${location_onnxruntime_header_dir}") |
| 148 | 148 | ||
| 149 | -if(ANDROID) | 149 | +if(DEFINED ENV{SHERPA_ONNXRUNTIME_LIB_DIR}) |
| 150 | set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.so) | 150 | set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.so) |
| 151 | + if(NOT EXISTS ${location_onnxruntime_lib}) | ||
| 152 | + set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a) | ||
| 153 | + endif() | ||
| 151 | else() | 154 | else() |
| 152 | find_library(location_onnxruntime_lib onnxruntime | 155 | find_library(location_onnxruntime_lib onnxruntime |
| 153 | PATHS | 156 | PATHS |
| @@ -14,7 +14,8 @@ ifeq ($(GDB), TRUE) | @@ -14,7 +14,8 @@ ifeq ($(GDB), TRUE) | ||
| 14 | OPTFLAG += -g | 14 | OPTFLAG += -g |
| 15 | endif | 15 | endif |
| 16 | 16 | ||
| 17 | -CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 -fopenmp ${OPTFLAG} | 17 | +# CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 -fopenmp ${OPTFLAG} |
| 18 | +CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 ${OPTFLAG} | ||
| 18 | LDLIBS := $(shell pkg-config --libs $(SHARED_LIBS)) | 19 | LDLIBS := $(shell pkg-config --libs $(SHARED_LIBS)) |
| 19 | 20 | ||
| 20 | CUR_DIR :=$(shell pwd) | 21 | CUR_DIR :=$(shell pwd) |
| 1 | +// !$*UTF8*$! | ||
| 2 | +{ | ||
| 3 | + archiveVersion = 1; | ||
| 4 | + classes = { | ||
| 5 | + }; | ||
| 6 | + objectVersion = 56; | ||
| 7 | + objects = { | ||
| 8 | + | ||
| 9 | +/* Begin PBXBuildFile section */ | ||
| 10 | + C984A7E829A9EEB700D74C52 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A7E729A9EEB700D74C52 /* AppDelegate.swift */; }; | ||
| 11 | + C984A7EA29A9EEB700D74C52 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A7E929A9EEB700D74C52 /* SceneDelegate.swift */; }; | ||
| 12 | + C984A7F129A9EEB900D74C52 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C984A7F029A9EEB900D74C52 /* Assets.xcassets */; }; | ||
| 13 | + C984A7F429A9EEB900D74C52 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C984A7F229A9EEB900D74C52 /* LaunchScreen.storyboard */; }; | ||
| 14 | + C984A7FF29A9EEBA00D74C52 /* SherpaOnnxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A7FE29A9EEBA00D74C52 /* SherpaOnnxTests.swift */; }; | ||
| 15 | + C984A80929A9EEBA00D74C52 /* SherpaOnnxUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A80829A9EEBA00D74C52 /* SherpaOnnxUITests.swift */; }; | ||
| 16 | + C984A80B29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A80A29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift */; }; | ||
| 17 | + C984A81929AA119400D74C52 /* SherpaOnnx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A81829AA119400D74C52 /* SherpaOnnx.swift */; }; | ||
| 18 | + C984A82829AA196100D74C52 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C984A82629AA196100D74C52 /* Main.storyboard */; }; | ||
| 19 | + C984A82A29AA19AC00D74C52 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A82929AA19AC00D74C52 /* Model.swift */; }; | ||
| 20 | + C984A83C29AA430B00D74C52 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A83B29AA430B00D74C52 /* ViewController.swift */; }; | ||
| 21 | + C984A83D29AA43D900D74C52 /* sherpa-onnx.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C984A81B29AA11C500D74C52 /* sherpa-onnx.xcframework */; }; | ||
| 22 | + C984A83F29AA43EE00D74C52 /* onnxruntime.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C984A83E29AA43EE00D74C52 /* onnxruntime.xcframework */; }; | ||
| 23 | +/* End PBXBuildFile section */ | ||
| 24 | + | ||
| 25 | +/* Begin PBXContainerItemProxy section */ | ||
| 26 | + C984A7FB29A9EEBA00D74C52 /* PBXContainerItemProxy */ = { | ||
| 27 | + isa = PBXContainerItemProxy; | ||
| 28 | + containerPortal = C984A7DC29A9EEB700D74C52 /* Project object */; | ||
| 29 | + proxyType = 1; | ||
| 30 | + remoteGlobalIDString = C984A7E329A9EEB700D74C52; | ||
| 31 | + remoteInfo = SherpaOnnx; | ||
| 32 | + }; | ||
| 33 | + C984A80529A9EEBA00D74C52 /* PBXContainerItemProxy */ = { | ||
| 34 | + isa = PBXContainerItemProxy; | ||
| 35 | + containerPortal = C984A7DC29A9EEB700D74C52 /* Project object */; | ||
| 36 | + proxyType = 1; | ||
| 37 | + remoteGlobalIDString = C984A7E329A9EEB700D74C52; | ||
| 38 | + remoteInfo = SherpaOnnx; | ||
| 39 | + }; | ||
| 40 | +/* End PBXContainerItemProxy section */ | ||
| 41 | + | ||
| 42 | +/* Begin PBXFileReference section */ | ||
| 43 | + C984A7E429A9EEB700D74C52 /* SherpaOnnx.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SherpaOnnx.app; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 44 | + C984A7E729A9EEB700D74C52 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; | ||
| 45 | + C984A7E929A9EEB700D74C52 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; }; | ||
| 46 | + C984A7F029A9EEB900D74C52 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; | ||
| 47 | + C984A7F329A9EEB900D74C52 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; | ||
| 48 | + C984A7F529A9EEB900D74C52 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | ||
| 49 | + C984A7FA29A9EEBA00D74C52 /* SherpaOnnxTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SherpaOnnxTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 50 | + C984A7FE29A9EEBA00D74C52 /* SherpaOnnxTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxTests.swift; sourceTree = "<group>"; }; | ||
| 51 | + C984A80429A9EEBA00D74C52 /* SherpaOnnxUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SherpaOnnxUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 52 | + C984A80829A9EEBA00D74C52 /* SherpaOnnxUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxUITests.swift; sourceTree = "<group>"; }; | ||
| 53 | + C984A80A29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxUITestsLaunchTests.swift; sourceTree = "<group>"; }; | ||
| 54 | + C984A81729A9F51B00D74C52 /* 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>"; }; | ||
| 55 | + C984A81829AA119400D74C52 /* SherpaOnnx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SherpaOnnx.swift; path = "../../../swift-api-examples/SherpaOnnx.swift"; sourceTree = "<group>"; }; | ||
| 56 | + C984A81B29AA11C500D74C52 /* sherpa-onnx.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = "sherpa-onnx.xcframework"; path = "../../build-ios/sherpa-onnx.xcframework"; sourceTree = "<group>"; }; | ||
| 57 | + C984A82029AA139600D74C52 /* onnxruntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = onnxruntime.xcframework; path = "../../build-ios/onnxruntime.xcframework"; sourceTree = "<group>"; }; | ||
| 58 | + C984A82729AA196100D74C52 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; | ||
| 59 | + C984A82929AA19AC00D74C52 /* Model.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; }; | ||
| 60 | + C984A83B29AA430B00D74C52 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; | ||
| 61 | + C984A83E29AA43EE00D74C52 /* onnxruntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = onnxruntime.xcframework; path = "../../build-ios/ios-onnxruntime/onnxruntime.xcframework"; sourceTree = "<group>"; }; | ||
| 62 | +/* End PBXFileReference section */ | ||
| 63 | + | ||
| 64 | +/* Begin PBXFrameworksBuildPhase section */ | ||
| 65 | + C984A7E129A9EEB700D74C52 /* Frameworks */ = { | ||
| 66 | + isa = PBXFrameworksBuildPhase; | ||
| 67 | + buildActionMask = 2147483647; | ||
| 68 | + files = ( | ||
| 69 | + C984A83F29AA43EE00D74C52 /* onnxruntime.xcframework in Frameworks */, | ||
| 70 | + C984A83D29AA43D900D74C52 /* sherpa-onnx.xcframework in Frameworks */, | ||
| 71 | + ); | ||
| 72 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 73 | + }; | ||
| 74 | + C984A7F729A9EEBA00D74C52 /* Frameworks */ = { | ||
| 75 | + isa = PBXFrameworksBuildPhase; | ||
| 76 | + buildActionMask = 2147483647; | ||
| 77 | + files = ( | ||
| 78 | + ); | ||
| 79 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 80 | + }; | ||
| 81 | + C984A80129A9EEBA00D74C52 /* Frameworks */ = { | ||
| 82 | + isa = PBXFrameworksBuildPhase; | ||
| 83 | + buildActionMask = 2147483647; | ||
| 84 | + files = ( | ||
| 85 | + ); | ||
| 86 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 87 | + }; | ||
| 88 | +/* End PBXFrameworksBuildPhase section */ | ||
| 89 | + | ||
| 90 | +/* Begin PBXGroup section */ | ||
| 91 | + C984A7DB29A9EEB700D74C52 = { | ||
| 92 | + isa = PBXGroup; | ||
| 93 | + children = ( | ||
| 94 | + C984A7E629A9EEB700D74C52 /* SherpaOnnx */, | ||
| 95 | + C984A7FD29A9EEBA00D74C52 /* SherpaOnnxTests */, | ||
| 96 | + C984A80729A9EEBA00D74C52 /* SherpaOnnxUITests */, | ||
| 97 | + C984A7E529A9EEB700D74C52 /* Products */, | ||
| 98 | + C984A81A29AA11C500D74C52 /* Frameworks */, | ||
| 99 | + ); | ||
| 100 | + sourceTree = "<group>"; | ||
| 101 | + }; | ||
| 102 | + C984A7E529A9EEB700D74C52 /* Products */ = { | ||
| 103 | + isa = PBXGroup; | ||
| 104 | + children = ( | ||
| 105 | + C984A7E429A9EEB700D74C52 /* SherpaOnnx.app */, | ||
| 106 | + C984A7FA29A9EEBA00D74C52 /* SherpaOnnxTests.xctest */, | ||
| 107 | + C984A80429A9EEBA00D74C52 /* SherpaOnnxUITests.xctest */, | ||
| 108 | + ); | ||
| 109 | + name = Products; | ||
| 110 | + sourceTree = "<group>"; | ||
| 111 | + }; | ||
| 112 | + C984A7E629A9EEB700D74C52 /* SherpaOnnx */ = { | ||
| 113 | + isa = PBXGroup; | ||
| 114 | + children = ( | ||
| 115 | + C984A83B29AA430B00D74C52 /* ViewController.swift */, | ||
| 116 | + C984A82929AA19AC00D74C52 /* Model.swift */, | ||
| 117 | + C984A81829AA119400D74C52 /* SherpaOnnx.swift */, | ||
| 118 | + C984A81729A9F51B00D74C52 /* SherpaOnnx-Bridging-Header.h */, | ||
| 119 | + C984A7E729A9EEB700D74C52 /* AppDelegate.swift */, | ||
| 120 | + C984A7E929A9EEB700D74C52 /* SceneDelegate.swift */, | ||
| 121 | + C984A82629AA196100D74C52 /* Main.storyboard */, | ||
| 122 | + C984A7F029A9EEB900D74C52 /* Assets.xcassets */, | ||
| 123 | + C984A7F229A9EEB900D74C52 /* LaunchScreen.storyboard */, | ||
| 124 | + C984A7F529A9EEB900D74C52 /* Info.plist */, | ||
| 125 | + ); | ||
| 126 | + path = SherpaOnnx; | ||
| 127 | + sourceTree = "<group>"; | ||
| 128 | + }; | ||
| 129 | + C984A7FD29A9EEBA00D74C52 /* SherpaOnnxTests */ = { | ||
| 130 | + isa = PBXGroup; | ||
| 131 | + children = ( | ||
| 132 | + C984A7FE29A9EEBA00D74C52 /* SherpaOnnxTests.swift */, | ||
| 133 | + ); | ||
| 134 | + path = SherpaOnnxTests; | ||
| 135 | + sourceTree = "<group>"; | ||
| 136 | + }; | ||
| 137 | + C984A80729A9EEBA00D74C52 /* SherpaOnnxUITests */ = { | ||
| 138 | + isa = PBXGroup; | ||
| 139 | + children = ( | ||
| 140 | + C984A80829A9EEBA00D74C52 /* SherpaOnnxUITests.swift */, | ||
| 141 | + C984A80A29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift */, | ||
| 142 | + ); | ||
| 143 | + path = SherpaOnnxUITests; | ||
| 144 | + sourceTree = "<group>"; | ||
| 145 | + }; | ||
| 146 | + C984A81A29AA11C500D74C52 /* Frameworks */ = { | ||
| 147 | + isa = PBXGroup; | ||
| 148 | + children = ( | ||
| 149 | + C984A82029AA139600D74C52 /* onnxruntime.xcframework */, | ||
| 150 | + C984A83E29AA43EE00D74C52 /* onnxruntime.xcframework */, | ||
| 151 | + C984A81B29AA11C500D74C52 /* sherpa-onnx.xcframework */, | ||
| 152 | + ); | ||
| 153 | + name = Frameworks; | ||
| 154 | + sourceTree = "<group>"; | ||
| 155 | + }; | ||
| 156 | +/* End PBXGroup section */ | ||
| 157 | + | ||
| 158 | +/* Begin PBXNativeTarget section */ | ||
| 159 | + C984A7E329A9EEB700D74C52 /* SherpaOnnx */ = { | ||
| 160 | + isa = PBXNativeTarget; | ||
| 161 | + buildConfigurationList = C984A80E29A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnx" */; | ||
| 162 | + buildPhases = ( | ||
| 163 | + C984A7E029A9EEB700D74C52 /* Sources */, | ||
| 164 | + C984A7E129A9EEB700D74C52 /* Frameworks */, | ||
| 165 | + C984A7E229A9EEB700D74C52 /* Resources */, | ||
| 166 | + ); | ||
| 167 | + buildRules = ( | ||
| 168 | + ); | ||
| 169 | + dependencies = ( | ||
| 170 | + ); | ||
| 171 | + name = SherpaOnnx; | ||
| 172 | + productName = SherpaOnnx; | ||
| 173 | + productReference = C984A7E429A9EEB700D74C52 /* SherpaOnnx.app */; | ||
| 174 | + productType = "com.apple.product-type.application"; | ||
| 175 | + }; | ||
| 176 | + C984A7F929A9EEBA00D74C52 /* SherpaOnnxTests */ = { | ||
| 177 | + isa = PBXNativeTarget; | ||
| 178 | + buildConfigurationList = C984A81129A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnxTests" */; | ||
| 179 | + buildPhases = ( | ||
| 180 | + C984A7F629A9EEBA00D74C52 /* Sources */, | ||
| 181 | + C984A7F729A9EEBA00D74C52 /* Frameworks */, | ||
| 182 | + C984A7F829A9EEBA00D74C52 /* Resources */, | ||
| 183 | + ); | ||
| 184 | + buildRules = ( | ||
| 185 | + ); | ||
| 186 | + dependencies = ( | ||
| 187 | + C984A7FC29A9EEBA00D74C52 /* PBXTargetDependency */, | ||
| 188 | + ); | ||
| 189 | + name = SherpaOnnxTests; | ||
| 190 | + productName = SherpaOnnxTests; | ||
| 191 | + productReference = C984A7FA29A9EEBA00D74C52 /* SherpaOnnxTests.xctest */; | ||
| 192 | + productType = "com.apple.product-type.bundle.unit-test"; | ||
| 193 | + }; | ||
| 194 | + C984A80329A9EEBA00D74C52 /* SherpaOnnxUITests */ = { | ||
| 195 | + isa = PBXNativeTarget; | ||
| 196 | + buildConfigurationList = C984A81429A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnxUITests" */; | ||
| 197 | + buildPhases = ( | ||
| 198 | + C984A80029A9EEBA00D74C52 /* Sources */, | ||
| 199 | + C984A80129A9EEBA00D74C52 /* Frameworks */, | ||
| 200 | + C984A80229A9EEBA00D74C52 /* Resources */, | ||
| 201 | + ); | ||
| 202 | + buildRules = ( | ||
| 203 | + ); | ||
| 204 | + dependencies = ( | ||
| 205 | + C984A80629A9EEBA00D74C52 /* PBXTargetDependency */, | ||
| 206 | + ); | ||
| 207 | + name = SherpaOnnxUITests; | ||
| 208 | + productName = SherpaOnnxUITests; | ||
| 209 | + productReference = C984A80429A9EEBA00D74C52 /* SherpaOnnxUITests.xctest */; | ||
| 210 | + productType = "com.apple.product-type.bundle.ui-testing"; | ||
| 211 | + }; | ||
| 212 | +/* End PBXNativeTarget section */ | ||
| 213 | + | ||
| 214 | +/* Begin PBXProject section */ | ||
| 215 | + C984A7DC29A9EEB700D74C52 /* Project object */ = { | ||
| 216 | + isa = PBXProject; | ||
| 217 | + attributes = { | ||
| 218 | + BuildIndependentTargetsInParallel = 1; | ||
| 219 | + LastSwiftUpdateCheck = 1420; | ||
| 220 | + LastUpgradeCheck = 1420; | ||
| 221 | + TargetAttributes = { | ||
| 222 | + C984A7E329A9EEB700D74C52 = { | ||
| 223 | + CreatedOnToolsVersion = 14.2; | ||
| 224 | + }; | ||
| 225 | + C984A7F929A9EEBA00D74C52 = { | ||
| 226 | + CreatedOnToolsVersion = 14.2; | ||
| 227 | + TestTargetID = C984A7E329A9EEB700D74C52; | ||
| 228 | + }; | ||
| 229 | + C984A80329A9EEBA00D74C52 = { | ||
| 230 | + CreatedOnToolsVersion = 14.2; | ||
| 231 | + TestTargetID = C984A7E329A9EEB700D74C52; | ||
| 232 | + }; | ||
| 233 | + }; | ||
| 234 | + }; | ||
| 235 | + buildConfigurationList = C984A7DF29A9EEB700D74C52 /* Build configuration list for PBXProject "SherpaOnnx" */; | ||
| 236 | + compatibilityVersion = "Xcode 14.0"; | ||
| 237 | + developmentRegion = en; | ||
| 238 | + hasScannedForEncodings = 0; | ||
| 239 | + knownRegions = ( | ||
| 240 | + en, | ||
| 241 | + Base, | ||
| 242 | + ); | ||
| 243 | + mainGroup = C984A7DB29A9EEB700D74C52; | ||
| 244 | + productRefGroup = C984A7E529A9EEB700D74C52 /* Products */; | ||
| 245 | + projectDirPath = ""; | ||
| 246 | + projectRoot = ""; | ||
| 247 | + targets = ( | ||
| 248 | + C984A7E329A9EEB700D74C52 /* SherpaOnnx */, | ||
| 249 | + C984A7F929A9EEBA00D74C52 /* SherpaOnnxTests */, | ||
| 250 | + C984A80329A9EEBA00D74C52 /* SherpaOnnxUITests */, | ||
| 251 | + ); | ||
| 252 | + }; | ||
| 253 | +/* End PBXProject section */ | ||
| 254 | + | ||
| 255 | +/* Begin PBXResourcesBuildPhase section */ | ||
| 256 | + C984A7E229A9EEB700D74C52 /* Resources */ = { | ||
| 257 | + isa = PBXResourcesBuildPhase; | ||
| 258 | + buildActionMask = 2147483647; | ||
| 259 | + files = ( | ||
| 260 | + C984A82829AA196100D74C52 /* Main.storyboard in Resources */, | ||
| 261 | + C984A7F429A9EEB900D74C52 /* LaunchScreen.storyboard in Resources */, | ||
| 262 | + C984A7F129A9EEB900D74C52 /* Assets.xcassets in Resources */, | ||
| 263 | + ); | ||
| 264 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 265 | + }; | ||
| 266 | + C984A7F829A9EEBA00D74C52 /* Resources */ = { | ||
| 267 | + isa = PBXResourcesBuildPhase; | ||
| 268 | + buildActionMask = 2147483647; | ||
| 269 | + files = ( | ||
| 270 | + ); | ||
| 271 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 272 | + }; | ||
| 273 | + C984A80229A9EEBA00D74C52 /* Resources */ = { | ||
| 274 | + isa = PBXResourcesBuildPhase; | ||
| 275 | + buildActionMask = 2147483647; | ||
| 276 | + files = ( | ||
| 277 | + ); | ||
| 278 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 279 | + }; | ||
| 280 | +/* End PBXResourcesBuildPhase section */ | ||
| 281 | + | ||
| 282 | +/* Begin PBXSourcesBuildPhase section */ | ||
| 283 | + C984A7E029A9EEB700D74C52 /* Sources */ = { | ||
| 284 | + isa = PBXSourcesBuildPhase; | ||
| 285 | + buildActionMask = 2147483647; | ||
| 286 | + files = ( | ||
| 287 | + C984A83C29AA430B00D74C52 /* ViewController.swift in Sources */, | ||
| 288 | + C984A82A29AA19AC00D74C52 /* Model.swift in Sources */, | ||
| 289 | + C984A81929AA119400D74C52 /* SherpaOnnx.swift in Sources */, | ||
| 290 | + C984A7E829A9EEB700D74C52 /* AppDelegate.swift in Sources */, | ||
| 291 | + C984A7EA29A9EEB700D74C52 /* SceneDelegate.swift in Sources */, | ||
| 292 | + ); | ||
| 293 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 294 | + }; | ||
| 295 | + C984A7F629A9EEBA00D74C52 /* Sources */ = { | ||
| 296 | + isa = PBXSourcesBuildPhase; | ||
| 297 | + buildActionMask = 2147483647; | ||
| 298 | + files = ( | ||
| 299 | + C984A7FF29A9EEBA00D74C52 /* SherpaOnnxTests.swift in Sources */, | ||
| 300 | + ); | ||
| 301 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 302 | + }; | ||
| 303 | + C984A80029A9EEBA00D74C52 /* Sources */ = { | ||
| 304 | + isa = PBXSourcesBuildPhase; | ||
| 305 | + buildActionMask = 2147483647; | ||
| 306 | + files = ( | ||
| 307 | + C984A80B29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift in Sources */, | ||
| 308 | + C984A80929A9EEBA00D74C52 /* SherpaOnnxUITests.swift in Sources */, | ||
| 309 | + ); | ||
| 310 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 311 | + }; | ||
| 312 | +/* End PBXSourcesBuildPhase section */ | ||
| 313 | + | ||
| 314 | +/* Begin PBXTargetDependency section */ | ||
| 315 | + C984A7FC29A9EEBA00D74C52 /* PBXTargetDependency */ = { | ||
| 316 | + isa = PBXTargetDependency; | ||
| 317 | + target = C984A7E329A9EEB700D74C52 /* SherpaOnnx */; | ||
| 318 | + targetProxy = C984A7FB29A9EEBA00D74C52 /* PBXContainerItemProxy */; | ||
| 319 | + }; | ||
| 320 | + C984A80629A9EEBA00D74C52 /* PBXTargetDependency */ = { | ||
| 321 | + isa = PBXTargetDependency; | ||
| 322 | + target = C984A7E329A9EEB700D74C52 /* SherpaOnnx */; | ||
| 323 | + targetProxy = C984A80529A9EEBA00D74C52 /* PBXContainerItemProxy */; | ||
| 324 | + }; | ||
| 325 | +/* End PBXTargetDependency section */ | ||
| 326 | + | ||
| 327 | +/* Begin PBXVariantGroup section */ | ||
| 328 | + C984A7F229A9EEB900D74C52 /* LaunchScreen.storyboard */ = { | ||
| 329 | + isa = PBXVariantGroup; | ||
| 330 | + children = ( | ||
| 331 | + C984A7F329A9EEB900D74C52 /* Base */, | ||
| 332 | + ); | ||
| 333 | + name = LaunchScreen.storyboard; | ||
| 334 | + sourceTree = "<group>"; | ||
| 335 | + }; | ||
| 336 | + C984A82629AA196100D74C52 /* Main.storyboard */ = { | ||
| 337 | + isa = PBXVariantGroup; | ||
| 338 | + children = ( | ||
| 339 | + C984A82729AA196100D74C52 /* Base */, | ||
| 340 | + ); | ||
| 341 | + name = Main.storyboard; | ||
| 342 | + sourceTree = "<group>"; | ||
| 343 | + }; | ||
| 344 | +/* End PBXVariantGroup section */ | ||
| 345 | + | ||
| 346 | +/* Begin XCBuildConfiguration section */ | ||
| 347 | + C984A80C29A9EEBA00D74C52 /* Debug */ = { | ||
| 348 | + isa = XCBuildConfiguration; | ||
| 349 | + buildSettings = { | ||
| 350 | + ALWAYS_SEARCH_USER_PATHS = NO; | ||
| 351 | + CLANG_ANALYZER_NONNULL = YES; | ||
| 352 | + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | ||
| 353 | + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; | ||
| 354 | + CLANG_ENABLE_MODULES = YES; | ||
| 355 | + CLANG_ENABLE_OBJC_ARC = YES; | ||
| 356 | + CLANG_ENABLE_OBJC_WEAK = YES; | ||
| 357 | + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
| 358 | + CLANG_WARN_BOOL_CONVERSION = YES; | ||
| 359 | + CLANG_WARN_COMMA = YES; | ||
| 360 | + CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
| 361 | + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
| 362 | + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
| 363 | + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | ||
| 364 | + CLANG_WARN_EMPTY_BODY = YES; | ||
| 365 | + CLANG_WARN_ENUM_CONVERSION = YES; | ||
| 366 | + CLANG_WARN_INFINITE_RECURSION = YES; | ||
| 367 | + CLANG_WARN_INT_CONVERSION = YES; | ||
| 368 | + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
| 369 | + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | ||
| 370 | + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
| 371 | + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
| 372 | + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; | ||
| 373 | + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
| 374 | + CLANG_WARN_STRICT_PROTOTYPES = YES; | ||
| 375 | + CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
| 376 | + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; | ||
| 377 | + CLANG_WARN_UNREACHABLE_CODE = YES; | ||
| 378 | + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
| 379 | + COPY_PHASE_STRIP = NO; | ||
| 380 | + DEBUG_INFORMATION_FORMAT = dwarf; | ||
| 381 | + ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
| 382 | + ENABLE_TESTABILITY = YES; | ||
| 383 | + GCC_C_LANGUAGE_STANDARD = gnu11; | ||
| 384 | + GCC_DYNAMIC_NO_PIC = NO; | ||
| 385 | + GCC_NO_COMMON_BLOCKS = YES; | ||
| 386 | + GCC_OPTIMIZATION_LEVEL = 0; | ||
| 387 | + GCC_PREPROCESSOR_DEFINITIONS = ( | ||
| 388 | + "DEBUG=1", | ||
| 389 | + "$(inherited)", | ||
| 390 | + ); | ||
| 391 | + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
| 392 | + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
| 393 | + GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
| 394 | + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
| 395 | + GCC_WARN_UNUSED_FUNCTION = YES; | ||
| 396 | + GCC_WARN_UNUSED_VARIABLE = YES; | ||
| 397 | + IPHONEOS_DEPLOYMENT_TARGET = 16.2; | ||
| 398 | + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; | ||
| 399 | + MTL_FAST_MATH = YES; | ||
| 400 | + ONLY_ACTIVE_ARCH = YES; | ||
| 401 | + SDKROOT = iphoneos; | ||
| 402 | + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; | ||
| 403 | + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | ||
| 404 | + }; | ||
| 405 | + name = Debug; | ||
| 406 | + }; | ||
| 407 | + C984A80D29A9EEBA00D74C52 /* Release */ = { | ||
| 408 | + isa = XCBuildConfiguration; | ||
| 409 | + buildSettings = { | ||
| 410 | + ALWAYS_SEARCH_USER_PATHS = NO; | ||
| 411 | + CLANG_ANALYZER_NONNULL = YES; | ||
| 412 | + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | ||
| 413 | + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; | ||
| 414 | + CLANG_ENABLE_MODULES = YES; | ||
| 415 | + CLANG_ENABLE_OBJC_ARC = YES; | ||
| 416 | + CLANG_ENABLE_OBJC_WEAK = YES; | ||
| 417 | + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
| 418 | + CLANG_WARN_BOOL_CONVERSION = YES; | ||
| 419 | + CLANG_WARN_COMMA = YES; | ||
| 420 | + CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
| 421 | + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
| 422 | + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
| 423 | + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | ||
| 424 | + CLANG_WARN_EMPTY_BODY = YES; | ||
| 425 | + CLANG_WARN_ENUM_CONVERSION = YES; | ||
| 426 | + CLANG_WARN_INFINITE_RECURSION = YES; | ||
| 427 | + CLANG_WARN_INT_CONVERSION = YES; | ||
| 428 | + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
| 429 | + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | ||
| 430 | + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
| 431 | + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
| 432 | + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; | ||
| 433 | + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
| 434 | + CLANG_WARN_STRICT_PROTOTYPES = YES; | ||
| 435 | + CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
| 436 | + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; | ||
| 437 | + CLANG_WARN_UNREACHABLE_CODE = YES; | ||
| 438 | + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
| 439 | + COPY_PHASE_STRIP = NO; | ||
| 440 | + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | ||
| 441 | + ENABLE_NS_ASSERTIONS = NO; | ||
| 442 | + ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
| 443 | + GCC_C_LANGUAGE_STANDARD = gnu11; | ||
| 444 | + GCC_NO_COMMON_BLOCKS = YES; | ||
| 445 | + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
| 446 | + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
| 447 | + GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
| 448 | + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
| 449 | + GCC_WARN_UNUSED_FUNCTION = YES; | ||
| 450 | + GCC_WARN_UNUSED_VARIABLE = YES; | ||
| 451 | + IPHONEOS_DEPLOYMENT_TARGET = 16.2; | ||
| 452 | + MTL_ENABLE_DEBUG_INFO = NO; | ||
| 453 | + MTL_FAST_MATH = YES; | ||
| 454 | + SDKROOT = iphoneos; | ||
| 455 | + SWIFT_COMPILATION_MODE = wholemodule; | ||
| 456 | + SWIFT_OPTIMIZATION_LEVEL = "-O"; | ||
| 457 | + VALIDATE_PRODUCT = YES; | ||
| 458 | + }; | ||
| 459 | + name = Release; | ||
| 460 | + }; | ||
| 461 | + C984A80F29A9EEBA00D74C52 /* Debug */ = { | ||
| 462 | + isa = XCBuildConfiguration; | ||
| 463 | + buildSettings = { | ||
| 464 | + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| 465 | + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; | ||
| 466 | + CODE_SIGN_STYLE = Automatic; | ||
| 467 | + CURRENT_PROJECT_VERSION = 1; | ||
| 468 | + GENERATE_INFOPLIST_FILE = YES; | ||
| 469 | + HEADER_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios/sherpa-onnx.xcframework/Headers/"; | ||
| 470 | + INFOPLIST_FILE = SherpaOnnx/Info.plist; | ||
| 471 | + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; | ||
| 472 | + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; | ||
| 473 | + INFOPLIST_KEY_UIMainStoryboardFile = Main; | ||
| 474 | + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; | ||
| 475 | + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; | ||
| 476 | + LD_RUNPATH_SEARCH_PATHS = ( | ||
| 477 | + "$(inherited)", | ||
| 478 | + "@executable_path/Frameworks", | ||
| 479 | + ); | ||
| 480 | + MARKETING_VERSION = 1.0; | ||
| 481 | + OTHER_LDFLAGS = "-lc++"; | ||
| 482 | + PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnx"; | ||
| 483 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 484 | + SWIFT_EMIT_LOC_STRINGS = YES; | ||
| 485 | + SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h"; | ||
| 486 | + SWIFT_VERSION = 5.0; | ||
| 487 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 488 | + }; | ||
| 489 | + name = Debug; | ||
| 490 | + }; | ||
| 491 | + C984A81029A9EEBA00D74C52 /* Release */ = { | ||
| 492 | + isa = XCBuildConfiguration; | ||
| 493 | + buildSettings = { | ||
| 494 | + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| 495 | + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; | ||
| 496 | + CODE_SIGN_STYLE = Automatic; | ||
| 497 | + CURRENT_PROJECT_VERSION = 1; | ||
| 498 | + GENERATE_INFOPLIST_FILE = YES; | ||
| 499 | + HEADER_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios/sherpa-onnx.xcframework/Headers/"; | ||
| 500 | + INFOPLIST_FILE = SherpaOnnx/Info.plist; | ||
| 501 | + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; | ||
| 502 | + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; | ||
| 503 | + INFOPLIST_KEY_UIMainStoryboardFile = Main; | ||
| 504 | + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; | ||
| 505 | + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; | ||
| 506 | + LD_RUNPATH_SEARCH_PATHS = ( | ||
| 507 | + "$(inherited)", | ||
| 508 | + "@executable_path/Frameworks", | ||
| 509 | + ); | ||
| 510 | + MARKETING_VERSION = 1.0; | ||
| 511 | + OTHER_LDFLAGS = "-lc++"; | ||
| 512 | + PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnx"; | ||
| 513 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 514 | + SWIFT_EMIT_LOC_STRINGS = YES; | ||
| 515 | + SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h"; | ||
| 516 | + SWIFT_VERSION = 5.0; | ||
| 517 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 518 | + }; | ||
| 519 | + name = Release; | ||
| 520 | + }; | ||
| 521 | + C984A81229A9EEBA00D74C52 /* Debug */ = { | ||
| 522 | + isa = XCBuildConfiguration; | ||
| 523 | + buildSettings = { | ||
| 524 | + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; | ||
| 525 | + BUNDLE_LOADER = "$(TEST_HOST)"; | ||
| 526 | + CODE_SIGN_STYLE = Automatic; | ||
| 527 | + CURRENT_PROJECT_VERSION = 1; | ||
| 528 | + GENERATE_INFOPLIST_FILE = YES; | ||
| 529 | + IPHONEOS_DEPLOYMENT_TARGET = 16.2; | ||
| 530 | + MARKETING_VERSION = 1.0; | ||
| 531 | + PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxTests"; | ||
| 532 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 533 | + SWIFT_EMIT_LOC_STRINGS = NO; | ||
| 534 | + SWIFT_VERSION = 5.0; | ||
| 535 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 536 | + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SherpaOnnx.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/SherpaOnnx"; | ||
| 537 | + }; | ||
| 538 | + name = Debug; | ||
| 539 | + }; | ||
| 540 | + C984A81329A9EEBA00D74C52 /* Release */ = { | ||
| 541 | + isa = XCBuildConfiguration; | ||
| 542 | + buildSettings = { | ||
| 543 | + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; | ||
| 544 | + BUNDLE_LOADER = "$(TEST_HOST)"; | ||
| 545 | + CODE_SIGN_STYLE = Automatic; | ||
| 546 | + CURRENT_PROJECT_VERSION = 1; | ||
| 547 | + GENERATE_INFOPLIST_FILE = YES; | ||
| 548 | + IPHONEOS_DEPLOYMENT_TARGET = 16.2; | ||
| 549 | + MARKETING_VERSION = 1.0; | ||
| 550 | + PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxTests"; | ||
| 551 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 552 | + SWIFT_EMIT_LOC_STRINGS = NO; | ||
| 553 | + SWIFT_VERSION = 5.0; | ||
| 554 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 555 | + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SherpaOnnx.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/SherpaOnnx"; | ||
| 556 | + }; | ||
| 557 | + name = Release; | ||
| 558 | + }; | ||
| 559 | + C984A81529A9EEBA00D74C52 /* Debug */ = { | ||
| 560 | + isa = XCBuildConfiguration; | ||
| 561 | + buildSettings = { | ||
| 562 | + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; | ||
| 563 | + CODE_SIGN_STYLE = Automatic; | ||
| 564 | + CURRENT_PROJECT_VERSION = 1; | ||
| 565 | + GENERATE_INFOPLIST_FILE = YES; | ||
| 566 | + MARKETING_VERSION = 1.0; | ||
| 567 | + PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxUITests"; | ||
| 568 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 569 | + SWIFT_EMIT_LOC_STRINGS = NO; | ||
| 570 | + SWIFT_VERSION = 5.0; | ||
| 571 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 572 | + TEST_TARGET_NAME = SherpaOnnx; | ||
| 573 | + }; | ||
| 574 | + name = Debug; | ||
| 575 | + }; | ||
| 576 | + C984A81629A9EEBA00D74C52 /* Release */ = { | ||
| 577 | + isa = XCBuildConfiguration; | ||
| 578 | + buildSettings = { | ||
| 579 | + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; | ||
| 580 | + CODE_SIGN_STYLE = Automatic; | ||
| 581 | + CURRENT_PROJECT_VERSION = 1; | ||
| 582 | + GENERATE_INFOPLIST_FILE = YES; | ||
| 583 | + MARKETING_VERSION = 1.0; | ||
| 584 | + PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxUITests"; | ||
| 585 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 586 | + SWIFT_EMIT_LOC_STRINGS = NO; | ||
| 587 | + SWIFT_VERSION = 5.0; | ||
| 588 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 589 | + TEST_TARGET_NAME = SherpaOnnx; | ||
| 590 | + }; | ||
| 591 | + name = Release; | ||
| 592 | + }; | ||
| 593 | +/* End XCBuildConfiguration section */ | ||
| 594 | + | ||
| 595 | +/* Begin XCConfigurationList section */ | ||
| 596 | + C984A7DF29A9EEB700D74C52 /* Build configuration list for PBXProject "SherpaOnnx" */ = { | ||
| 597 | + isa = XCConfigurationList; | ||
| 598 | + buildConfigurations = ( | ||
| 599 | + C984A80C29A9EEBA00D74C52 /* Debug */, | ||
| 600 | + C984A80D29A9EEBA00D74C52 /* Release */, | ||
| 601 | + ); | ||
| 602 | + defaultConfigurationIsVisible = 0; | ||
| 603 | + defaultConfigurationName = Release; | ||
| 604 | + }; | ||
| 605 | + C984A80E29A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnx" */ = { | ||
| 606 | + isa = XCConfigurationList; | ||
| 607 | + buildConfigurations = ( | ||
| 608 | + C984A80F29A9EEBA00D74C52 /* Debug */, | ||
| 609 | + C984A81029A9EEBA00D74C52 /* Release */, | ||
| 610 | + ); | ||
| 611 | + defaultConfigurationIsVisible = 0; | ||
| 612 | + defaultConfigurationName = Release; | ||
| 613 | + }; | ||
| 614 | + C984A81129A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnxTests" */ = { | ||
| 615 | + isa = XCConfigurationList; | ||
| 616 | + buildConfigurations = ( | ||
| 617 | + C984A81229A9EEBA00D74C52 /* Debug */, | ||
| 618 | + C984A81329A9EEBA00D74C52 /* Release */, | ||
| 619 | + ); | ||
| 620 | + defaultConfigurationIsVisible = 0; | ||
| 621 | + defaultConfigurationName = Release; | ||
| 622 | + }; | ||
| 623 | + C984A81429A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnxUITests" */ = { | ||
| 624 | + isa = XCConfigurationList; | ||
| 625 | + buildConfigurations = ( | ||
| 626 | + C984A81529A9EEBA00D74C52 /* Debug */, | ||
| 627 | + C984A81629A9EEBA00D74C52 /* Release */, | ||
| 628 | + ); | ||
| 629 | + defaultConfigurationIsVisible = 0; | ||
| 630 | + defaultConfigurationName = Release; | ||
| 631 | + }; | ||
| 632 | +/* End XCConfigurationList section */ | ||
| 633 | + }; | ||
| 634 | + rootObject = C984A7DC29A9EEB700D74C52 /* Project object */; | ||
| 635 | +} |
不能预览此文件类型
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 3 | +<plist version="1.0"> | ||
| 4 | +<dict> | ||
| 5 | + <key>SchemeUserState</key> | ||
| 6 | + <dict> | ||
| 7 | + <key>SherpaOnnx.xcscheme_^#shared#^_</key> | ||
| 8 | + <dict> | ||
| 9 | + <key>orderHint</key> | ||
| 10 | + <integer>0</integer> | ||
| 11 | + </dict> | ||
| 12 | + </dict> | ||
| 13 | +</dict> | ||
| 14 | +</plist> |
| 1 | +// | ||
| 2 | +// AppDelegate.swift | ||
| 3 | +// SherpaOnnx | ||
| 4 | +// | ||
| 5 | +// Created by fangjun on 2023/2/25. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import UIKit | ||
| 9 | + | ||
| 10 | +@main | ||
| 11 | +class AppDelegate: UIResponder, UIApplicationDelegate { | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
| 16 | + // Override point for customization after application launch. | ||
| 17 | + return true | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + // MARK: UISceneSession Lifecycle | ||
| 21 | + | ||
| 22 | + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { | ||
| 23 | + // Called when a new scene session is being created. | ||
| 24 | + // Use this method to select a configuration to create the new scene with. | ||
| 25 | + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { | ||
| 29 | + // Called when the user discards a scene session. | ||
| 30 | + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. | ||
| 31 | + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + | ||
| 35 | +} | ||
| 36 | + |
411.2 KB
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
| 3 | + <dependencies> | ||
| 4 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> | ||
| 5 | + <capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
| 6 | + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
| 7 | + </dependencies> | ||
| 8 | + <scenes> | ||
| 9 | + <!--View Controller--> | ||
| 10 | + <scene sceneID="EHf-IW-A2E"> | ||
| 11 | + <objects> | ||
| 12 | + <viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
| 13 | + <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
| 14 | + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
| 15 | + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| 16 | + <color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | ||
| 17 | + <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
| 18 | + </view> | ||
| 19 | + </viewController> | ||
| 20 | + <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
| 21 | + </objects> | ||
| 22 | + <point key="canvasLocation" x="53" y="375"/> | ||
| 23 | + </scene> | ||
| 24 | + </scenes> | ||
| 25 | +</document> |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> | ||
| 3 | + <device id="retina6_12" orientation="portrait" appearance="light"/> | ||
| 4 | + <dependencies> | ||
| 5 | + <deployment identifier="iOS"/> | ||
| 6 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/> | ||
| 7 | + <capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
| 8 | + <capability name="System colors in document resources" minToolsVersion="11.0"/> | ||
| 9 | + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
| 10 | + </dependencies> | ||
| 11 | + <scenes> | ||
| 12 | + <!--View Controller--> | ||
| 13 | + <scene sceneID="tne-QT-ifu"> | ||
| 14 | + <objects> | ||
| 15 | + <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="SherpaNcnn" customModuleProvider="target" sceneMemberID="viewController"> | ||
| 16 | + <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> | ||
| 17 | + <rect key="frame" x="0.0" y="0.0" width="393" height="852"/> | ||
| 18 | + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| 19 | + <subviews> | ||
| 20 | + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7q8-Y3-WbJ"> | ||
| 21 | + <rect key="frame" x="166" y="773" width="61.333333333333343" height="35"/> | ||
| 22 | + <state key="normal" title="Button"/> | ||
| 23 | + <buttonConfiguration key="configuration" style="plain" title="Start"/> | ||
| 24 | + <connections> | ||
| 25 | + <action selector="onRecordBtnClick:" destination="BYZ-38-t0r" eventType="touchUpInside" id="rS6-DT-XWm"/> | ||
| 26 | + </connections> | ||
| 27 | + </button> | ||
| 28 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jfS-7J-m9C"> | ||
| 29 | + <rect key="frame" x="8" y="67" width="377" height="20.333333333333329"/> | ||
| 30 | + <fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
| 31 | + <nil key="textColor"/> | ||
| 32 | + <nil key="highlightedColor"/> | ||
| 33 | + </label> | ||
| 34 | + </subviews> | ||
| 35 | + <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
| 36 | + <color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
| 37 | + <constraints> | ||
| 38 | + <constraint firstItem="jfS-7J-m9C" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="8" id="HX3-rI-U9E"/> | ||
| 39 | + <constraint firstItem="jfS-7J-m9C" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="8" id="NEv-PD-DHj"/> | ||
| 40 | + <constraint firstItem="7q8-Y3-WbJ" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="Nha-gf-R2b"/> | ||
| 41 | + <constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="jfS-7J-m9C" secondAttribute="trailing" constant="8" id="P2f-hG-O2e"/> | ||
| 42 | + <constraint firstAttribute="bottomMargin" secondItem="7q8-Y3-WbJ" secondAttribute="bottom" constant="10" id="Pgb-4G-ySa"/> | ||
| 43 | + </constraints> | ||
| 44 | + </view> | ||
| 45 | + <connections> | ||
| 46 | + <outlet property="recordBtn" destination="7q8-Y3-WbJ" id="mFd-cu-zjn"/> | ||
| 47 | + <outlet property="resultLabel" destination="jfS-7J-m9C" id="xQU-ID-m5Q"/> | ||
| 48 | + </connections> | ||
| 49 | + </viewController> | ||
| 50 | + <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> | ||
| 51 | + </objects> | ||
| 52 | + <point key="canvasLocation" x="32.824427480916029" y="3.5211267605633805"/> | ||
| 53 | + </scene> | ||
| 54 | + </scenes> | ||
| 55 | + <resources> | ||
| 56 | + <systemColor name="systemBackgroundColor"> | ||
| 57 | + <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| 58 | + </systemColor> | ||
| 59 | + </resources> | ||
| 60 | +</document> |
ios-swift/SherpaOnnx/SherpaOnnx/Info.plist
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 3 | +<plist version="1.0"> | ||
| 4 | +<dict> | ||
| 5 | + <key>NSMicrophoneUsageDescription</key> | ||
| 6 | + <string>Need microphone access for Next-gen Kaldi to work</string> | ||
| 7 | + <key>UIApplicationSceneManifest</key> | ||
| 8 | + <dict> | ||
| 9 | + <key>UIApplicationSupportsMultipleScenes</key> | ||
| 10 | + <false/> | ||
| 11 | + <key>UISceneConfigurations</key> | ||
| 12 | + <dict> | ||
| 13 | + <key>UIWindowSceneSessionRoleApplication</key> | ||
| 14 | + <array> | ||
| 15 | + <dict> | ||
| 16 | + <key>UISceneConfigurationName</key> | ||
| 17 | + <string>Default Configuration</string> | ||
| 18 | + <key>UISceneDelegateClassName</key> | ||
| 19 | + <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> | ||
| 20 | + <key>UISceneStoryboardFile</key> | ||
| 21 | + <string>Main</string> | ||
| 22 | + </dict> | ||
| 23 | + </array> | ||
| 24 | + </dict> | ||
| 25 | + </dict> | ||
| 26 | +</dict> | ||
| 27 | +</plist> |
ios-swift/SherpaOnnx/SherpaOnnx/Model.swift
0 → 100644
| 1 | +import Foundation | ||
| 2 | + | ||
| 3 | +func getResource(_ forResource: String, _ ofType: String) -> String { | ||
| 4 | + let path = Bundle.main.path(forResource: forResource, ofType: ofType) | ||
| 5 | + precondition( | ||
| 6 | + path != nil, | ||
| 7 | + "\(forResource).\(ofType) does not exist!\n" + "Remember to change \n" | ||
| 8 | + + " Build Phases -> Copy Bundle Resources\n" + "to add it!" | ||
| 9 | + ) | ||
| 10 | + return path! | ||
| 11 | +} | ||
| 12 | +/// Please refer to | ||
| 13 | +/// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html | ||
| 14 | +/// to download pre-trained models | ||
| 15 | + | ||
| 16 | +/// sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 (Bilingual, Chinese + English) | ||
| 17 | +/// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/zipformer-transducer-models.html | ||
| 18 | +func getBilingualStreamZhEnZipformer20230220() -> SherpaOnnxOnlineTransducerModelConfig { | ||
| 19 | + let encoder = getResource("encoder-epoch-99-avg-1", "onnx") | ||
| 20 | + let decoder = getResource("decoder-epoch-99-avg-1", "onnx") | ||
| 21 | + let joiner = getResource("joiner-epoch-99-avg-1", "onnx") | ||
| 22 | + let tokens = getResource("tokens", "txt") | ||
| 23 | + | ||
| 24 | + return sherpaOnnxOnlineTransducerModelConfig( | ||
| 25 | + encoder: encoder, | ||
| 26 | + decoder: decoder, | ||
| 27 | + joiner: joiner, | ||
| 28 | + tokens: tokens, | ||
| 29 | + numThreads: 2 | ||
| 30 | + ) | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +/// Please refer to | ||
| 34 | +/// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html | ||
| 35 | +/// to add more models if you need |
| 1 | +// | ||
| 2 | +// SceneDelegate.swift | ||
| 3 | +// SherpaOnnx | ||
| 4 | +// | ||
| 5 | +// Created by fangjun on 2023/2/25. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import UIKit | ||
| 9 | + | ||
| 10 | +class SceneDelegate: UIResponder, UIWindowSceneDelegate { | ||
| 11 | + | ||
| 12 | + var window: UIWindow? | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | ||
| 16 | + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. | ||
| 17 | + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. | ||
| 18 | + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). | ||
| 19 | + guard let _ = (scene as? UIWindowScene) else { return } | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + func sceneDidDisconnect(_ scene: UIScene) { | ||
| 23 | + // Called as the scene is being released by the system. | ||
| 24 | + // This occurs shortly after the scene enters the background, or when its session is discarded. | ||
| 25 | + // Release any resources associated with this scene that can be re-created the next time the scene connects. | ||
| 26 | + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + func sceneDidBecomeActive(_ scene: UIScene) { | ||
| 30 | + // Called when the scene has moved from an inactive state to an active state. | ||
| 31 | + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + func sceneWillResignActive(_ scene: UIScene) { | ||
| 35 | + // Called when the scene will move from an active state to an inactive state. | ||
| 36 | + // This may occur due to temporary interruptions (ex. an incoming phone call). | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + func sceneWillEnterForeground(_ scene: UIScene) { | ||
| 40 | + // Called as the scene transitions from the background to the foreground. | ||
| 41 | + // Use this method to undo the changes made on entering the background. | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + func sceneDidEnterBackground(_ scene: UIScene) { | ||
| 45 | + // Called as the scene transitions from the foreground to the background. | ||
| 46 | + // Use this method to save data, release shared resources, and store enough scene-specific state information | ||
| 47 | + // to restore the scene back to its current state. | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + | ||
| 51 | +} | ||
| 52 | + |
| 1 | +// | ||
| 2 | +// ViewController.swift | ||
| 3 | +// SherpaOnnx | ||
| 4 | +// | ||
| 5 | +// Created by fangjun on 2023/1/28. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import AVFoundation | ||
| 9 | +import UIKit | ||
| 10 | + | ||
| 11 | +extension AudioBuffer { | ||
| 12 | + func array() -> [Float] { | ||
| 13 | + return Array(UnsafeBufferPointer(self)) | ||
| 14 | + } | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +extension AVAudioPCMBuffer { | ||
| 18 | + func array() -> [Float] { | ||
| 19 | + return self.audioBufferList.pointee.mBuffers.array() | ||
| 20 | + } | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +class ViewController: UIViewController { | ||
| 24 | + @IBOutlet weak var resultLabel: UILabel! | ||
| 25 | + @IBOutlet weak var recordBtn: UIButton! | ||
| 26 | + | ||
| 27 | + var audioEngine: AVAudioEngine? = nil | ||
| 28 | + var recognizer: SherpaOnnxRecognizer! = nil | ||
| 29 | + | ||
| 30 | + /// It saves the decoded results so far | ||
| 31 | + var sentences: [String] = [] { | ||
| 32 | + didSet { | ||
| 33 | + updateLabel() | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + var lastSentence: String = "" | ||
| 37 | + let maxSentence: Int = 20 | ||
| 38 | + var results: String { | ||
| 39 | + if sentences.isEmpty && lastSentence.isEmpty { | ||
| 40 | + return "" | ||
| 41 | + } | ||
| 42 | + if sentences.isEmpty { | ||
| 43 | + return "0: \(lastSentence.lowercased())" | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + let start = max(sentences.count - maxSentence, 0) | ||
| 47 | + if lastSentence.isEmpty { | ||
| 48 | + return sentences.enumerated().map { (index, s) in "\(index): \(s.lowercased())" }[start...] | ||
| 49 | + .joined(separator: "\n") | ||
| 50 | + } else { | ||
| 51 | + return sentences.enumerated().map { (index, s) in "\(index): \(s.lowercased())" }[start...] | ||
| 52 | + .joined(separator: "\n") + "\n\(sentences.count): \(lastSentence.lowercased())" | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + func updateLabel() { | ||
| 57 | + DispatchQueue.main.async { | ||
| 58 | + self.resultLabel.text = self.results | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + override func viewDidLoad() { | ||
| 63 | + super.viewDidLoad() | ||
| 64 | + // Do any additional setup after loading the view. | ||
| 65 | + | ||
| 66 | + resultLabel.text = "ASR with Next-gen Kaldi\n\nPress the Start button to run!" | ||
| 67 | + recordBtn.setTitle("Start", for: .normal) | ||
| 68 | + initRecognizer() | ||
| 69 | + initRecorder() | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @IBAction func onRecordBtnClick(_ sender: UIButton) { | ||
| 73 | + if recordBtn.currentTitle == "Start" { | ||
| 74 | + startRecorder() | ||
| 75 | + recordBtn.setTitle("Stop", for: .normal) | ||
| 76 | + } else { | ||
| 77 | + stopRecorder() | ||
| 78 | + recordBtn.setTitle("Start", for: .normal) | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + func initRecognizer() { | ||
| 83 | + // Please select one model that is best suitable for you. | ||
| 84 | + // | ||
| 85 | + // You can also modify Model.swift to add new pre-trained models from | ||
| 86 | + // https://k2-fsa.github.io/sherpa/ncnn/pretrained_models/index.html | ||
| 87 | + | ||
| 88 | + let modelConfig = getBilingualStreamZhEnZipformer20230220() | ||
| 89 | + | ||
| 90 | + let featConfig = sherpaOnnxFeatureConfig( | ||
| 91 | + sampleRate: 16000, | ||
| 92 | + featureDim: 80) | ||
| 93 | + | ||
| 94 | + var config = sherpaOnnxOnlineRecognizerConfig( | ||
| 95 | + featConfig: featConfig, | ||
| 96 | + modelConfig: modelConfig, | ||
| 97 | + enableEndpoint: true, | ||
| 98 | + rule1MinTrailingSilence: 2.4, | ||
| 99 | + rule2MinTrailingSilence: 0.8, | ||
| 100 | + rule3MinUtteranceLength: 30 | ||
| 101 | + ) | ||
| 102 | + recognizer = SherpaOnnxRecognizer(config: &config) | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + func initRecorder() { | ||
| 106 | + print("init recorder") | ||
| 107 | + audioEngine = AVAudioEngine() | ||
| 108 | + let inputNode = self.audioEngine?.inputNode | ||
| 109 | + let bus = 0 | ||
| 110 | + let inputFormat = inputNode?.outputFormat(forBus: bus) | ||
| 111 | + let outputFormat = AVAudioFormat( | ||
| 112 | + commonFormat: .pcmFormatFloat32, | ||
| 113 | + sampleRate: 16000, channels: 1, | ||
| 114 | + interleaved: false)! | ||
| 115 | + | ||
| 116 | + let converter = AVAudioConverter(from: inputFormat!, to: outputFormat)! | ||
| 117 | + | ||
| 118 | + inputNode!.installTap( | ||
| 119 | + onBus: bus, | ||
| 120 | + bufferSize: 1024, | ||
| 121 | + format: inputFormat | ||
| 122 | + ) { | ||
| 123 | + (buffer: AVAudioPCMBuffer, when: AVAudioTime) in | ||
| 124 | + var newBufferAvailable = true | ||
| 125 | + | ||
| 126 | + let inputCallback: AVAudioConverterInputBlock = { | ||
| 127 | + inNumPackets, outStatus in | ||
| 128 | + if newBufferAvailable { | ||
| 129 | + outStatus.pointee = .haveData | ||
| 130 | + newBufferAvailable = false | ||
| 131 | + | ||
| 132 | + return buffer | ||
| 133 | + } else { | ||
| 134 | + outStatus.pointee = .noDataNow | ||
| 135 | + return nil | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + let convertedBuffer = AVAudioPCMBuffer( | ||
| 140 | + pcmFormat: outputFormat, | ||
| 141 | + frameCapacity: | ||
| 142 | + AVAudioFrameCount(outputFormat.sampleRate) | ||
| 143 | + * buffer.frameLength | ||
| 144 | + / AVAudioFrameCount(buffer.format.sampleRate))! | ||
| 145 | + | ||
| 146 | + var error: NSError? | ||
| 147 | + let _ = converter.convert( | ||
| 148 | + to: convertedBuffer, | ||
| 149 | + error: &error, withInputFrom: inputCallback) | ||
| 150 | + | ||
| 151 | + // TODO(fangjun): Handle status != haveData | ||
| 152 | + | ||
| 153 | + let array = convertedBuffer.array() | ||
| 154 | + if !array.isEmpty { | ||
| 155 | + self.recognizer.acceptWaveform(samples: array) | ||
| 156 | + while (self.recognizer.isReady()){ | ||
| 157 | + self.recognizer.decode() | ||
| 158 | + } | ||
| 159 | + let isEndpoint = self.recognizer.isEndpoint() | ||
| 160 | + let text = self.recognizer.getResult().text | ||
| 161 | + | ||
| 162 | + if !text.isEmpty && self.lastSentence != text { | ||
| 163 | + self.lastSentence = text | ||
| 164 | + self.updateLabel() | ||
| 165 | + print(text) | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + if isEndpoint { | ||
| 169 | + if !text.isEmpty { | ||
| 170 | + let tmp = self.lastSentence | ||
| 171 | + self.lastSentence = "" | ||
| 172 | + self.sentences.append(tmp) | ||
| 173 | + } | ||
| 174 | + self.recognizer.reset() | ||
| 175 | + } | ||
| 176 | + } | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + func startRecorder() { | ||
| 182 | + lastSentence = "" | ||
| 183 | + sentences = [] | ||
| 184 | + | ||
| 185 | + do { | ||
| 186 | + try self.audioEngine?.start() | ||
| 187 | + } catch let error as NSError { | ||
| 188 | + print("Got an error starting audioEngine: \(error.domain), \(error)") | ||
| 189 | + } | ||
| 190 | + print("started") | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + func stopRecorder() { | ||
| 194 | + audioEngine?.stop() | ||
| 195 | + print("stopped") | ||
| 196 | + } | ||
| 197 | +} |
411.2 KB
| 1 | +// | ||
| 2 | +// SherpaOnnxTests.swift | ||
| 3 | +// SherpaOnnxTests | ||
| 4 | +// | ||
| 5 | +// Created by fangjun on 2023/2/25. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import XCTest | ||
| 9 | +@testable import SherpaOnnx | ||
| 10 | + | ||
| 11 | +final class SherpaOnnxTests: XCTestCase { | ||
| 12 | + | ||
| 13 | + override func setUpWithError() throws { | ||
| 14 | + // Put setup code here. This method is called before the invocation of each test method in the class. | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + override func tearDownWithError() throws { | ||
| 18 | + // Put teardown code here. This method is called after the invocation of each test method in the class. | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + func testExample() throws { | ||
| 22 | + // This is an example of a functional test case. | ||
| 23 | + // Use XCTAssert and related functions to verify your tests produce the correct results. | ||
| 24 | + // Any test you write for XCTest can be annotated as throws and async. | ||
| 25 | + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. | ||
| 26 | + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + func testPerformanceExample() throws { | ||
| 30 | + // This is an example of a performance test case. | ||
| 31 | + self.measure { | ||
| 32 | + // Put the code you want to measure the time of here. | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | +} |
| 1 | +// | ||
| 2 | +// SherpaOnnxUITests.swift | ||
| 3 | +// SherpaOnnxUITests | ||
| 4 | +// | ||
| 5 | +// Created by fangjun on 2023/2/25. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import XCTest | ||
| 9 | + | ||
| 10 | +final class SherpaOnnxUITests: XCTestCase { | ||
| 11 | + | ||
| 12 | + override func setUpWithError() throws { | ||
| 13 | + // Put setup code here. This method is called before the invocation of each test method in the class. | ||
| 14 | + | ||
| 15 | + // In UI tests it is usually best to stop immediately when a failure occurs. | ||
| 16 | + continueAfterFailure = false | ||
| 17 | + | ||
| 18 | + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + override func tearDownWithError() throws { | ||
| 22 | + // Put teardown code here. This method is called after the invocation of each test method in the class. | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + func testExample() throws { | ||
| 26 | + // UI tests must launch the application that they test. | ||
| 27 | + let app = XCUIApplication() | ||
| 28 | + app.launch() | ||
| 29 | + | ||
| 30 | + // Use XCTAssert and related functions to verify your tests produce the correct results. | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + func testLaunchPerformance() throws { | ||
| 34 | + if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { | ||
| 35 | + // This measures how long it takes to launch your application. | ||
| 36 | + measure(metrics: [XCTApplicationLaunchMetric()]) { | ||
| 37 | + XCUIApplication().launch() | ||
| 38 | + } | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | +} |
| 1 | +// | ||
| 2 | +// SherpaOnnxUITestsLaunchTests.swift | ||
| 3 | +// SherpaOnnxUITests | ||
| 4 | +// | ||
| 5 | +// Created by fangjun on 2023/2/25. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import XCTest | ||
| 9 | + | ||
| 10 | +final class SherpaOnnxUITestsLaunchTests: XCTestCase { | ||
| 11 | + | ||
| 12 | + override class var runsForEachTargetApplicationUIConfiguration: Bool { | ||
| 13 | + true | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + override func setUpWithError() throws { | ||
| 17 | + continueAfterFailure = false | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + func testLaunch() throws { | ||
| 21 | + let app = XCUIApplication() | ||
| 22 | + app.launch() | ||
| 23 | + | ||
| 24 | + // Insert steps here to perform after app launch but before taking a screenshot, | ||
| 25 | + // such as logging into a test account or navigating somewhere in the app | ||
| 26 | + | ||
| 27 | + let attachment = XCTAttachment(screenshot: app.screenshot()) | ||
| 28 | + attachment.name = "Launch Screen" | ||
| 29 | + attachment.lifetime = .keepAlways | ||
| 30 | + add(attachment) | ||
| 31 | + } | ||
| 32 | +} |
| @@ -160,14 +160,17 @@ class OnlineRecognizer::Impl { | @@ -160,14 +160,17 @@ class OnlineRecognizer::Impl { | ||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | void Reset(OnlineStream *s) const { | 162 | void Reset(OnlineStream *s) const { |
| 163 | - // reset result and neural network model state, | ||
| 164 | - // but keep the feature extractor state | 163 | + // reset result, neural network model state, and |
| 164 | + // the feature extractor state | ||
| 165 | 165 | ||
| 166 | // reset result | 166 | // reset result |
| 167 | s->SetResult(decoder_->GetEmptyResult()); | 167 | s->SetResult(decoder_->GetEmptyResult()); |
| 168 | 168 | ||
| 169 | // reset neural network model state | 169 | // reset neural network model state |
| 170 | s->SetStates(model_->GetEncoderInitStates()); | 170 | s->SetStates(model_->GetEncoderInitStates()); |
| 171 | + | ||
| 172 | + // reset feature extractor | ||
| 173 | + s->Reset(); | ||
| 171 | } | 174 | } |
| 172 | 175 | ||
| 173 | private: | 176 | private: |
| @@ -32,7 +32,10 @@ class OnlineStream::Impl { | @@ -32,7 +32,10 @@ class OnlineStream::Impl { | ||
| 32 | return feat_extractor_.GetFrames(frame_index, n); | 32 | return feat_extractor_.GetFrames(frame_index, n); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | - void Reset() { feat_extractor_.Reset(); } | 35 | + void Reset() { |
| 36 | + feat_extractor_.Reset(); | ||
| 37 | + num_processed_frames_ = 0; | ||
| 38 | + } | ||
| 36 | 39 | ||
| 37 | int32_t &GetNumProcessedFrames() { return num_processed_frames_; } | 40 | int32_t &GetNumProcessedFrames() { return num_processed_frames_; } |
| 38 | 41 |
| 1 | +// swfit-api-examples/SherpaOnnx-Bridging-Header.h | ||
| 2 | +// | ||
| 3 | +// Copyright (c) 2023 Xiaomi Corporation | ||
| 4 | +#ifndef SWIFT_API_EXAMPLES_SHERPAONNX_BRIDGING_HEADER_H_ | ||
| 5 | +#define SWIFT_API_EXAMPLES_SHERPAONNX_BRIDGING_HEADER_H_ | ||
| 6 | + | ||
| 7 | +#import "sherpa-onnx/c-api/c-api.h" | ||
| 8 | + | ||
| 9 | +#endif // SWIFT_API_EXAMPLES_SHERPAONNX_BRIDGING_HEADER_H_ |
swift-api-examples/SherpaOnnx.swift
0 → 100644
| 1 | +/// swfit-api-examples/SherpaOnnx.swift | ||
| 2 | +/// Copyright (c) 2023 Xiaomi Corporation | ||
| 3 | + | ||
| 4 | +import Foundation // For NSString | ||
| 5 | + | ||
| 6 | +/// Convert a String from swift to a `const char*` so that we can pass it to | ||
| 7 | +/// the C language. | ||
| 8 | +/// | ||
| 9 | +/// - Parameters: | ||
| 10 | +/// - s: The String to convert. | ||
| 11 | +/// - Returns: A pointer that can be passed to C as `const char*` | ||
| 12 | + | ||
| 13 | +func toCPointer(_ s: String) -> UnsafePointer<Int8>! { | ||
| 14 | + let cs = (s as NSString).utf8String | ||
| 15 | + return UnsafePointer<Int8>(cs) | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +/// Return an instance of SherpaOnnxOnlineTransducerModelConfig. | ||
| 19 | +/// | ||
| 20 | +/// Please refer to | ||
| 21 | +/// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html | ||
| 22 | +/// to download the required `.onnx` files. | ||
| 23 | +/// | ||
| 24 | +/// - Parameters: | ||
| 25 | +/// - encoder: Path to encoder.onnx | ||
| 26 | +/// - decoder: Path to decoder.onnx | ||
| 27 | +/// - joiner: Path to joiner.onnx | ||
| 28 | +/// - tokens: Path to tokens.txt | ||
| 29 | +/// - numThreads: Number of threads to use for neural network computation. | ||
| 30 | +/// | ||
| 31 | +/// - Returns: Return an instance of SherpaOnnxOnlineTransducerModelConfig | ||
| 32 | +func sherpaOnnxOnlineTransducerModelConfig( | ||
| 33 | + encoder: String, | ||
| 34 | + decoder: String, | ||
| 35 | + joiner: String, | ||
| 36 | + tokens: String, | ||
| 37 | + numThreads: Int = 2, | ||
| 38 | + debug: Int = 0 | ||
| 39 | +) -> SherpaOnnxOnlineTransducerModelConfig{ | ||
| 40 | + return SherpaOnnxOnlineTransducerModelConfig( | ||
| 41 | + encoder: toCPointer(encoder), | ||
| 42 | + decoder: toCPointer(decoder), | ||
| 43 | + joiner: toCPointer(joiner), | ||
| 44 | + tokens: toCPointer(tokens), | ||
| 45 | + num_threads: Int32(numThreads), | ||
| 46 | + debug: Int32(debug) | ||
| 47 | + ) | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +func sherpaOnnxFeatureConfig( | ||
| 51 | + sampleRate: Int = 16000, | ||
| 52 | + featureDim: Int = 80 | ||
| 53 | +) -> SherpaOnnxFeatureConfig { | ||
| 54 | + return SherpaOnnxFeatureConfig( | ||
| 55 | + sample_rate: Int32(sampleRate), | ||
| 56 | + feature_dim: Int32(featureDim)) | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +func sherpaOnnxOnlineRecognizerConfig( | ||
| 60 | + featConfig: SherpaOnnxFeatureConfig, | ||
| 61 | + modelConfig: SherpaOnnxOnlineTransducerModelConfig, | ||
| 62 | + enableEndpoint: Bool = false, | ||
| 63 | + rule1MinTrailingSilence: Float = 2.4, | ||
| 64 | + rule2MinTrailingSilence: Float = 1.2, | ||
| 65 | + rule3MinUtteranceLength: Float = 30 | ||
| 66 | +) -> SherpaOnnxOnlineRecognizerConfig{ | ||
| 67 | + return SherpaOnnxOnlineRecognizerConfig( | ||
| 68 | + feat_config: featConfig, | ||
| 69 | + model_config: modelConfig, | ||
| 70 | + enable_endpoint: enableEndpoint ? 1 : 0, | ||
| 71 | + rule1_min_trailing_silence: rule1MinTrailingSilence, | ||
| 72 | + rule2_min_trailing_silence: rule2MinTrailingSilence, | ||
| 73 | + rule3_min_utterance_length: rule3MinUtteranceLength) | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +/// Wrapper for recognition result. | ||
| 77 | +/// | ||
| 78 | +/// Usage: | ||
| 79 | +/// | ||
| 80 | +/// let result = recognizer.getResult() | ||
| 81 | +/// print("text: \(result.text)") | ||
| 82 | +/// | ||
| 83 | +class SherpaOnnxOnlineRecongitionResult { | ||
| 84 | + /// A pointer to the underlying counterpart in C | ||
| 85 | + let result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>! | ||
| 86 | + | ||
| 87 | + /// Return the actual recognition result. | ||
| 88 | + /// For English models, it contains words separated by spaces. | ||
| 89 | + /// For Chinese models, it contains Chinese words. | ||
| 90 | + var text: String { | ||
| 91 | + return String(cString: result.pointee.text) | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + init(result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>!) { | ||
| 95 | + self.result = result | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + deinit { | ||
| 99 | + if let result { | ||
| 100 | + DestroyOnlineRecognizerResult(result) | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +class SherpaOnnxRecognizer { | ||
| 106 | + /// A pointer to the underlying counterpart in C | ||
| 107 | + let recognizer: OpaquePointer! | ||
| 108 | + let stream: OpaquePointer! | ||
| 109 | + | ||
| 110 | + /// Constructor taking a model config and a decoder config. | ||
| 111 | + init( | ||
| 112 | + config: UnsafePointer<SherpaOnnxOnlineRecognizerConfig>! | ||
| 113 | + ) { | ||
| 114 | + recognizer = CreateOnlineRecognizer(config) | ||
| 115 | + stream = CreateOnlineStream(recognizer) | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + deinit { | ||
| 119 | + if let stream { | ||
| 120 | + DestoryOnlineStream(stream) | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + if let recognizer { | ||
| 124 | + DestroyOnlineRecognizer(recognizer) | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + /// Decode wave samples. | ||
| 129 | + /// | ||
| 130 | + /// - Parameters: | ||
| 131 | + /// - samples: Audio samples normalzed to the range [-1, 1] | ||
| 132 | + /// - sampleRate: Sample rate of the input audio samples. Must match | ||
| 133 | + /// the one expected by the model. It must be 16000 for | ||
| 134 | + /// models from icefall. | ||
| 135 | + func acceptWaveform(samples: [Float], sampleRate: Float = 16000) { | ||
| 136 | + AcceptWaveform(stream, sampleRate, samples, Int32(samples.count)) | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + func isReady() -> Bool { | ||
| 140 | + return IsOnlineStreamReady(recognizer, stream) == 1 ? true : false | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + /// If there are enough number of feature frames, it invokes the neural | ||
| 144 | + /// network computation and decoding. Otherwise, it is a no-op. | ||
| 145 | + func decode() { | ||
| 146 | + DecodeOnlineStream(recognizer, stream) | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + /// Get the decoding results so far | ||
| 150 | + func getResult() -> SherpaOnnxOnlineRecongitionResult { | ||
| 151 | + let result: UnsafeMutablePointer<SherpaOnnxOnlineRecognizerResult>? = GetOnlineStreamResult(recognizer, stream) | ||
| 152 | + return SherpaOnnxOnlineRecongitionResult(result: result) | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + /// Reset the recognizer, which clears the neural network model state | ||
| 156 | + /// and the state for decoding. | ||
| 157 | + func reset() { | ||
| 158 | + Reset(recognizer, stream) | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /// Signal that no more audio samples would be available. | ||
| 162 | + /// After this call, you cannot call acceptWaveform() any more. | ||
| 163 | + func inputFinished() { | ||
| 164 | + InputFinished(stream) | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + /// Return true is an endpoint has been detected. | ||
| 168 | + func isEndpoint() -> Bool { | ||
| 169 | + return IsEndpoint(recognizer, stream) == 1 ? true : false | ||
| 170 | + } | ||
| 171 | +} |
swift-api-examples/decode-file.swift
0 → 100644
| 1 | +import AVFoundation | ||
| 2 | + | ||
| 3 | +extension AudioBuffer { | ||
| 4 | + func array() -> [Float] { | ||
| 5 | + return Array(UnsafeBufferPointer(self)) | ||
| 6 | + } | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +extension AVAudioPCMBuffer { | ||
| 10 | + func array() -> [Float] { | ||
| 11 | + return self.audioBufferList.pointee.mBuffers.array() | ||
| 12 | + } | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +func run() { | ||
| 16 | + let encoder = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.onnx" | ||
| 17 | + let decoder = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx" | ||
| 18 | + let joiner = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.onnx" | ||
| 19 | + let tokens = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt" | ||
| 20 | + | ||
| 21 | + let modelConfig = sherpaOnnxOnlineTransducerModelConfig( | ||
| 22 | + encoder: encoder, | ||
| 23 | + decoder: decoder, | ||
| 24 | + joiner: joiner, | ||
| 25 | + tokens: tokens, | ||
| 26 | + numThreads: 2) | ||
| 27 | + | ||
| 28 | + let featConfig = sherpaOnnxFeatureConfig( | ||
| 29 | + sampleRate: 16000, | ||
| 30 | + featureDim: 80 | ||
| 31 | + ) | ||
| 32 | + var config = sherpaOnnxOnlineRecognizerConfig( | ||
| 33 | + featConfig: featConfig, | ||
| 34 | + modelConfig: modelConfig, | ||
| 35 | + enableEndpoint: false | ||
| 36 | + ) | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + let recognizer = SherpaOnnxRecognizer(config: &config) | ||
| 40 | + | ||
| 41 | + let filePath = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/test_wavs/1.wav" | ||
| 42 | + let fileURL: NSURL = NSURL(fileURLWithPath: filePath) | ||
| 43 | + let audioFile = try! AVAudioFile(forReading: fileURL as URL) | ||
| 44 | + | ||
| 45 | + let audioFormat = audioFile.processingFormat | ||
| 46 | + assert(audioFormat.sampleRate == 16000) | ||
| 47 | + assert(audioFormat.channelCount == 1) | ||
| 48 | + assert(audioFormat.commonFormat == AVAudioCommonFormat.pcmFormatFloat32) | ||
| 49 | + | ||
| 50 | + let audioFrameCount = UInt32(audioFile.length) | ||
| 51 | + let audioFileBuffer = AVAudioPCMBuffer(pcmFormat: audioFormat, frameCapacity: audioFrameCount) | ||
| 52 | + | ||
| 53 | + try! audioFile.read(into: audioFileBuffer!) | ||
| 54 | + let array: [Float]! = audioFileBuffer?.array() | ||
| 55 | + recognizer.acceptWaveform(samples: array) | ||
| 56 | + | ||
| 57 | + let tailPadding = [Float](repeating: 0.0, count: 3200) | ||
| 58 | + recognizer.acceptWaveform(samples: tailPadding) | ||
| 59 | + | ||
| 60 | + recognizer.inputFinished() | ||
| 61 | + while (recognizer.isReady()) { | ||
| 62 | + recognizer.decode() | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + let result = recognizer.getResult() | ||
| 66 | + print("\nresult is:\n\(result.text)") | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +@main | ||
| 70 | +struct App { | ||
| 71 | + static func main() { | ||
| 72 | + run() | ||
| 73 | + } | ||
| 74 | +} |
swift-api-examples/run-decode-file.sh
0 → 100755
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +set -ex | ||
| 4 | + | ||
| 5 | +if [ ! -d ../build-swift-macos ]; then | ||
| 6 | + echo "Please run ../build-swift-macos.sh first!" | ||
| 7 | + exit 1 | ||
| 8 | +fi | ||
| 9 | + | ||
| 10 | +if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then | ||
| 11 | + echo "Please download the pre-trained model for testing." | ||
| 12 | + echo "You can refer to" | ||
| 13 | + echo "" | ||
| 14 | + echo "https://k2-fsa.github.io/sherpa/onnx/pretrained_models/zipformer-transducer-models.html#sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20-bilingual-chinese-english" | ||
| 15 | + echo "" | ||
| 16 | + echo "for help" | ||
| 17 | + exit 1 | ||
| 18 | +fi | ||
| 19 | + | ||
| 20 | +if [ ! -e ./decode-file ]; then | ||
| 21 | + # Note: We use -lc++ to link against libc++ instead of libstdc++ | ||
| 22 | + swiftc \ | ||
| 23 | + -lc++ \ | ||
| 24 | + -I ../build-swift-macos/install/include \ | ||
| 25 | + -import-objc-header ./SherpaOnnx-Bridging-Header.h \ | ||
| 26 | + ./decode-file.swift ./SherpaOnnx.swift \ | ||
| 27 | + -L ../build-swift-macos/install/lib/ \ | ||
| 28 | + -l sherpa-onnx \ | ||
| 29 | + -l onnxruntime \ | ||
| 30 | + -o decode-file | ||
| 31 | +else | ||
| 32 | + echo "./decode-file exists - skip building" | ||
| 33 | +fi | ||
| 34 | + | ||
| 35 | +export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH | ||
| 36 | +./decode-file |
toolchains/ios.toolchain.cmake
0 → 100644
| 1 | +# This file is part of the ios-cmake project. It was retrieved from | ||
| 2 | +# https://github.com/leetal/ios-cmake.git, which is a fork of | ||
| 3 | +# https://github.com/gerstrong/ios-cmake.git, which is a fork of | ||
| 4 | +# https://github.com/cristeab/ios-cmake.git, which is a fork of | ||
| 5 | +# https://code.google.com/p/ios-cmake/. Which in turn is based off of | ||
| 6 | +# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which | ||
| 7 | +# are included with CMake 2.8.4 | ||
| 8 | +# | ||
| 9 | +# The ios-cmake project is licensed under the new BSD license. | ||
| 10 | +# | ||
| 11 | +# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software, | ||
| 12 | +# Kitware, Inc., Insight Software Consortium. All rights reserved. | ||
| 13 | +# Redistribution and use in source and binary forms, with or without | ||
| 14 | +# modification, are permitted provided that the following conditions | ||
| 15 | +# are met: | ||
| 16 | +# 1. Redistributions of source code must retain the above copyright | ||
| 17 | +# notice, this list of conditions and the following disclaimer. | ||
| 18 | +# | ||
| 19 | +# 2. Redistributions in binary form must reproduce the above copyright | ||
| 20 | +# notice, this list of conditions and the following disclaimer in the | ||
| 21 | +# documentation and/or other materials provided with the distribution. | ||
| 22 | +# | ||
| 23 | +# 3. Neither the name of the copyright holder nor the names of its | ||
| 24 | +# contributors may be used to endorse or promote products derived from | ||
| 25 | +# this software without specific prior written permission. | ||
| 26 | +# | ||
| 27 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 28 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 29 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 30 | +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 31 | +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 32 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 33 | +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 34 | +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 35 | +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 36 | +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| 37 | +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 38 | +# POSSIBILITY OF SUCH DAMAGE. | ||
| 39 | +# | ||
| 40 | +# This file is based off of the Platform/Darwin.cmake and | ||
| 41 | +# Platform/UnixPaths.cmake files which are included with CMake 2.8.4 | ||
| 42 | +# It has been altered for iOS development. | ||
| 43 | +# | ||
| 44 | +# Updated by Alex Stewart (alexs.mac@gmail.com) | ||
| 45 | +# | ||
| 46 | +# ***************************************************************************** | ||
| 47 | +# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com) | ||
| 48 | +# under the BSD-3-Clause license | ||
| 49 | +# https://github.com/leetal/ios-cmake | ||
| 50 | +# ***************************************************************************** | ||
| 51 | +# | ||
| 52 | +# INFORMATION / HELP | ||
| 53 | +# | ||
| 54 | +# The following options control the behaviour of this toolchain: | ||
| 55 | +# | ||
| 56 | +# PLATFORM: (default "OS64") | ||
| 57 | +# OS = Build for iPhoneOS. | ||
| 58 | +# OS64 = Build for arm64 iphoneOS. | ||
| 59 | +# OS64COMBINED = Build for arm64 x86_64 iphoneOS. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY) | ||
| 60 | +# SIMULATOR = Build for x86 i386 iphoneOS Simulator. | ||
| 61 | +# SIMULATOR64 = Build for x86_64 iphoneOS Simulator. | ||
| 62 | +# SIMULATORARM64 = Build for arm64 iphoneOS Simulator. | ||
| 63 | +# TVOS = Build for arm64 tvOS. | ||
| 64 | +# TVOSCOMBINED = Build for arm64 x86_64 tvOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY) | ||
| 65 | +# SIMULATOR_TVOS = Build for x86_64 tvOS Simulator. | ||
| 66 | +# WATCHOS = Build for armv7k arm64_32 for watchOS. | ||
| 67 | +# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY) | ||
| 68 | +# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator. | ||
| 69 | +# MAC = Build for x86_64 macOS. | ||
| 70 | +# MAC_ARM64 = Build for Apple Silicon macOS. | ||
| 71 | +# MAC_CATALYST = Build for x86_64 macOS with Catalyst support (iOS toolchain on macOS). | ||
| 72 | +# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS | ||
| 73 | +# MAC_CATALYST_ARM64 = Build for Apple Silicon macOS with Catalyst support (iOS toolchain on macOS). | ||
| 74 | +# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS | ||
| 75 | +# | ||
| 76 | +# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is | ||
| 77 | +# automatically determined from PLATFORM and xcodebuild, but | ||
| 78 | +# can also be manually specified (although this should not be required). | ||
| 79 | +# | ||
| 80 | +# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform | ||
| 81 | +# being compiled for. By default this is automatically determined from | ||
| 82 | +# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should | ||
| 83 | +# not be required). | ||
| 84 | +# | ||
| 85 | +# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 2.0 on watchOS and 9.0 on tvOS+iOS | ||
| 86 | +# | ||
| 87 | +# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true) | ||
| 88 | +# | ||
| 89 | +# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default) | ||
| 90 | +# | ||
| 91 | +# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default) | ||
| 92 | +# | ||
| 93 | +# ENABLE_STRICT_TRY_COMPILE: (1|0) Enables or disables strict try_compile() on all Check* directives (will run linker | ||
| 94 | +# to actually check if linking is possible). Default 0 (false, will set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY) | ||
| 95 | +# | ||
| 96 | +# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will override the default architectures for the given PLATFORM | ||
| 97 | +# OS = armv7 armv7s arm64 (if applicable) | ||
| 98 | +# OS64 = arm64 (if applicable) | ||
| 99 | +# SIMULATOR = i386 | ||
| 100 | +# SIMULATOR64 = x86_64 | ||
| 101 | +# SIMULATORARM64 = arm64 | ||
| 102 | +# TVOS = arm64 | ||
| 103 | +# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated) | ||
| 104 | +# WATCHOS = armv7k arm64_32 (if applicable) | ||
| 105 | +# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated) | ||
| 106 | +# MAC = x86_64 | ||
| 107 | +# MAC_ARM64 = arm64 | ||
| 108 | +# MAC_CATALYST = x86_64 | ||
| 109 | +# MAC_CATALYST_ARM64 = arm64 | ||
| 110 | +# | ||
| 111 | +# This toolchain defines the following properties (available via get_property()) for use externally: | ||
| 112 | +# | ||
| 113 | +# PLATFORM: The currently targeted platform. | ||
| 114 | +# XCODE_VERSION: Version number (not including Build version) of Xcode detected. | ||
| 115 | +# SDK_VERSION: Version of SDK being used. | ||
| 116 | +# OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM). | ||
| 117 | +# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" are overridden, this will *NOT* be set! | ||
| 118 | +# | ||
| 119 | +# This toolchain defines the following macros for use externally: | ||
| 120 | +# | ||
| 121 | +# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT) | ||
| 122 | +# A convenience macro for setting xcode specific properties on targets. | ||
| 123 | +# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel | ||
| 124 | +# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all"). | ||
| 125 | +# | ||
| 126 | +# find_host_package (PROGRAM ARGS) | ||
| 127 | +# A macro used to find executable programs on the host system, not within the | ||
| 128 | +# environment. Thanks to the android-cmake project for providing the | ||
| 129 | +# command. | ||
| 130 | +# | ||
| 131 | + | ||
| 132 | +cmake_minimum_required(VERSION 3.8.0) | ||
| 133 | + | ||
| 134 | +# CMake invokes the toolchain file twice during the first build, but only once during subsequent rebuilds. | ||
| 135 | +if(IOS_TOOLCHAIN_HAS_RUN) | ||
| 136 | + return() | ||
| 137 | +endif(IOS_TOOLCHAIN_HAS_RUN) | ||
| 138 | +set(IOS_TOOLCHAIN_HAS_RUN true) | ||
| 139 | + | ||
| 140 | +############################################################################### | ||
| 141 | +# OPTIONS # | ||
| 142 | +############################################################################### | ||
| 143 | + | ||
| 144 | +option(DROP_32_BIT "Drops the 32-bit targets universally." YES) | ||
| 145 | + | ||
| 146 | +############################################################################### | ||
| 147 | +# END OPTIONS # | ||
| 148 | +############################################################################### | ||
| 149 | + | ||
| 150 | +# List of supported platform values | ||
| 151 | +list(APPEND _supported_platforms | ||
| 152 | + "OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64" | ||
| 153 | + "TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS" | ||
| 154 | + "WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" | ||
| 155 | + "MAC" "MAC_ARM64" | ||
| 156 | + "MAC_CATALYST" "MAC_CATALYST_ARM64") | ||
| 157 | + | ||
| 158 | +# Cache what generator is used | ||
| 159 | +set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}") | ||
| 160 | + | ||
| 161 | +# Check if using a CMake version capable of building combined FAT builds (simulator and target slices combined in one static lib) | ||
| 162 | +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14") | ||
| 163 | + set(MODERN_CMAKE YES) | ||
| 164 | +endif() | ||
| 165 | + | ||
| 166 | +# Get the Xcode version being used. | ||
| 167 | +# Problem: CMake runs toolchain files multiple times, but can't read cache variables on some runs. | ||
| 168 | +# Workaround: On first run (in which cache variables are always accessible), set an intermediary environment variable. | ||
| 169 | +# | ||
| 170 | +# NOTE: This pattern is used i many places in this toolchain to speed up checks of all sorts | ||
| 171 | +if(DEFINED XCODE_VERSION_INT) | ||
| 172 | + # Environment variables are always preserved. | ||
| 173 | + set(ENV{_XCODE_VERSION_INT} "${XCODE_VERSION_INT}") | ||
| 174 | +elseif(DEFINED ENV{_XCODE_VERSION_INT}) | ||
| 175 | + set(XCODE_VERSION_INT "$ENV{_XCODE_VERSION_INT}") | ||
| 176 | +elseif(NOT DEFINED XCODE_VERSION_INT) | ||
| 177 | + find_program(XCODEBUILD_EXECUTABLE xcodebuild) | ||
| 178 | + if(NOT XCODEBUILD_EXECUTABLE) | ||
| 179 | + message(FATAL_ERROR "xcodebuild not found. Please install either the standalone commandline tools or Xcode.") | ||
| 180 | + endif() | ||
| 181 | + execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -version | ||
| 182 | + OUTPUT_VARIABLE XCODE_VERSION_INT | ||
| 183 | + ERROR_QUIET | ||
| 184 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 185 | + string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION_INT "${XCODE_VERSION_INT}") | ||
| 186 | + string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION_INT "${XCODE_VERSION_INT}") | ||
| 187 | + set(XCODE_VERSION_INT "${XCODE_VERSION_INT}" CACHE INTERNAL "") | ||
| 188 | +endif() | ||
| 189 | + | ||
| 190 | +# Assuming that xcode 12.0 is installed you most probably have ios sdk 14.0 or later installed (tested on Big Sur) | ||
| 191 | +# if you don't set a deployment target it will be set the way you only get 64-bit builds | ||
| 192 | +if(NOT DEFINED DEPLOYMENT_TARGET AND XCODE_VERSION_INT VERSION_GREATER 12.0) | ||
| 193 | + # Temporarily fix the arm64 issues in CMake install-combined by excluding arm64 for simulator builds (needed for Apple Silicon...) | ||
| 194 | + set(CMAKE_XCODE_ATTRIBUTE_EXCLUDED_ARCHS[sdk=iphonesimulator*] "arm64") | ||
| 195 | +endif() | ||
| 196 | + | ||
| 197 | +# Check if the platform variable is set | ||
| 198 | +if(DEFINED PLATFORM) | ||
| 199 | + # Environment variables are always preserved. | ||
| 200 | + set(ENV{_PLATFORM} "${PLATFORM}") | ||
| 201 | +elseif(DEFINED ENV{_PLATFORM}) | ||
| 202 | + set(PLATFORM "$ENV{_PLATFORM}") | ||
| 203 | +elseif(NOT DEFINED PLATFORM) | ||
| 204 | + message(FATAL_ERROR "PLATFORM argument not set. Bailing configure since I don't know what target you want to build for!") | ||
| 205 | +endif () | ||
| 206 | + | ||
| 207 | +# Safeguard that the platform value is set and is one of the supported values | ||
| 208 | +list(FIND _supported_platforms ${PLATFORM} contains_PLATFORM) | ||
| 209 | +if("${contains_PLATFORM}" EQUAL "-1") | ||
| 210 | + string(REPLACE ";" "\n * " _supported_platforms_formatted "${_supported_platforms}") | ||
| 211 | + message(FATAL_ERROR " Invalid PLATFORM specified! Current value: ${PLATFORM}.\n" | ||
| 212 | + " Supported PLATFORM values: \n * ${_supported_platforms_formatted}") | ||
| 213 | +endif() | ||
| 214 | + | ||
| 215 | +# Check if Apple Silicon is supported | ||
| 216 | +if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5") | ||
| 217 | + message(FATAL_ERROR "Apple Silicon builds requires a minimum of CMake 3.19.5") | ||
| 218 | +endif() | ||
| 219 | + | ||
| 220 | +# Touch toolchain variable to suppress "unused variable" warning. | ||
| 221 | +# This happens if CMake is invoked with the same command line the second time. | ||
| 222 | +if(CMAKE_TOOLCHAIN_FILE) | ||
| 223 | +endif() | ||
| 224 | + | ||
| 225 | +# Fix for PThread library not in path | ||
| 226 | +set(CMAKE_THREAD_LIBS_INIT "-lpthread") | ||
| 227 | +set(CMAKE_HAVE_THREADS_LIBRARY 1) | ||
| 228 | +set(CMAKE_USE_WIN32_THREADS_INIT 0) | ||
| 229 | +set(CMAKE_USE_PTHREADS_INIT 1) | ||
| 230 | + | ||
| 231 | +# Specify minimum version of deployment target. | ||
| 232 | +if(NOT DEFINED DEPLOYMENT_TARGET) | ||
| 233 | + if (PLATFORM MATCHES "WATCHOS") | ||
| 234 | + # Unless specified, SDK version 4.0 is used by default as minimum target version (watchOS). | ||
| 235 | + set(DEPLOYMENT_TARGET "4.0") | ||
| 236 | + elseif(PLATFORM STREQUAL "MAC") | ||
| 237 | + # Unless specified, SDK version 10.13 (High sierra) is used by default as minimum target version (macos). | ||
| 238 | + set(DEPLOYMENT_TARGET "10.13") | ||
| 239 | + elseif(PLATFORM STREQUAL "MAC_ARM64") | ||
| 240 | + # Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version (macos on arm). | ||
| 241 | + set(DEPLOYMENT_TARGET "11.0") | ||
| 242 | + elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") | ||
| 243 | + # Unless specified, SDK version 13.0 is used by default as minimum target version (mac catalyst minimum requirement). | ||
| 244 | + set(DEPLOYMENT_TARGET "13.0") | ||
| 245 | + else() | ||
| 246 | + # Unless specified, SDK version 11.0 is used by default as minimum target version (iOS, tvOS). | ||
| 247 | + set(DEPLOYMENT_TARGET "11.0") | ||
| 248 | + endif() | ||
| 249 | + message(STATUS "[DEFAULTS] Using the default min-version since DEPLOYMENT_TARGET not provided!") | ||
| 250 | +elseif(DEFINED DEPLOYMENT_TARGET AND PLATFORM STREQUAL "MAC_CATALYST" AND ${DEPLOYMENT_TARGET} VERSION_LESS "13.0") | ||
| 251 | + message(FATAL_ERROR "Mac Catalyst builds requires a minimum deployment target of 13.0!") | ||
| 252 | +endif() | ||
| 253 | + | ||
| 254 | +# Store the DEPLOYMENT_TARGET in the cache | ||
| 255 | +set(DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}" CACHE INTERNAL "") | ||
| 256 | + | ||
| 257 | +# Handle the case where we are targeting iOS and a version above 10.3.4 (32-bit support dropped officially) | ||
| 258 | +if(PLATFORM STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) | ||
| 259 | + set(PLATFORM "OS64") | ||
| 260 | + message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") | ||
| 261 | +elseif(PLATFORM STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) | ||
| 262 | + set(PLATFORM "SIMULATOR64") | ||
| 263 | + message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") | ||
| 264 | +endif() | ||
| 265 | + | ||
| 266 | +set(PLATFORM_INT "${PLATFORM}") | ||
| 267 | + | ||
| 268 | +if(DEFINED ARCHS) | ||
| 269 | + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") | ||
| 270 | +endif() | ||
| 271 | + | ||
| 272 | +# Determine the platform name and architectures for use in xcodebuild commands | ||
| 273 | +# from the specified PLATFORM_INT name. | ||
| 274 | +if(PLATFORM_INT STREQUAL "OS") | ||
| 275 | + set(SDK_NAME iphoneos) | ||
| 276 | + if(NOT ARCHS) | ||
| 277 | + set(ARCHS armv7 armv7s arm64) | ||
| 278 | + set(APPLE_TARGET_TRIPLE_INT arm-apple-ios) | ||
| 279 | + endif() | ||
| 280 | +elseif(PLATFORM_INT STREQUAL "OS64") | ||
| 281 | + set(SDK_NAME iphoneos) | ||
| 282 | + if(NOT ARCHS) | ||
| 283 | + if (XCODE_VERSION_INT VERSION_GREATER 10.0) | ||
| 284 | + set(ARCHS arm64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example | ||
| 285 | + else() | ||
| 286 | + set(ARCHS arm64) | ||
| 287 | + endif() | ||
| 288 | + set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios) | ||
| 289 | + else() | ||
| 290 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios) | ||
| 291 | + endif() | ||
| 292 | +elseif(PLATFORM_INT STREQUAL "OS64COMBINED") | ||
| 293 | + set(SDK_NAME iphoneos) | ||
| 294 | + if(MODERN_CMAKE) | ||
| 295 | + if(NOT ARCHS) | ||
| 296 | + if (XCODE_VERSION_INT VERSION_GREATER 10.0) | ||
| 297 | + set(ARCHS arm64 x86_64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example | ||
| 298 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64") | ||
| 299 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64") | ||
| 300 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64") | ||
| 301 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64") | ||
| 302 | + else() | ||
| 303 | + set(ARCHS arm64 x86_64) | ||
| 304 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64") | ||
| 305 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64") | ||
| 306 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64") | ||
| 307 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64") | ||
| 308 | + endif() | ||
| 309 | + set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios) | ||
| 310 | + else() | ||
| 311 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios) | ||
| 312 | + endif() | ||
| 313 | + else() | ||
| 314 | + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work") | ||
| 315 | + endif() | ||
| 316 | +elseif(PLATFORM_INT STREQUAL "SIMULATOR") | ||
| 317 | + set(SDK_NAME iphonesimulator) | ||
| 318 | + if(NOT ARCHS) | ||
| 319 | + set(ARCHS i386) | ||
| 320 | + set(APPLE_TARGET_TRIPLE_INT i386-apple-ios) | ||
| 321 | + else() | ||
| 322 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios) | ||
| 323 | + endif() | ||
| 324 | + message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.") | ||
| 325 | +elseif(PLATFORM_INT STREQUAL "SIMULATOR64") | ||
| 326 | + set(SDK_NAME iphonesimulator) | ||
| 327 | + if(NOT ARCHS) | ||
| 328 | + set(ARCHS x86_64) | ||
| 329 | + set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios) | ||
| 330 | + else() | ||
| 331 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios) | ||
| 332 | + endif() | ||
| 333 | +elseif(PLATFORM_INT STREQUAL "SIMULATORARM64") | ||
| 334 | + set(SDK_NAME iphonesimulator) | ||
| 335 | + if(NOT ARCHS) | ||
| 336 | + set(ARCHS arm64) | ||
| 337 | + set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios) | ||
| 338 | + else() | ||
| 339 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios) | ||
| 340 | + endif() | ||
| 341 | +elseif(PLATFORM_INT STREQUAL "TVOS") | ||
| 342 | + set(SDK_NAME appletvos) | ||
| 343 | + if(NOT ARCHS) | ||
| 344 | + set(ARCHS arm64) | ||
| 345 | + set(APPLE_TARGET_TRIPLE_INT aarch64-apple-tvos) | ||
| 346 | + else() | ||
| 347 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos) | ||
| 348 | + endif() | ||
| 349 | +elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED") | ||
| 350 | + set(SDK_NAME appletvos) | ||
| 351 | + if(MODERN_CMAKE) | ||
| 352 | + if(NOT ARCHS) | ||
| 353 | + set(ARCHS arm64 x86_64) | ||
| 354 | + set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-tvos) | ||
| 355 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvos*] "arm64") | ||
| 356 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvsimulator*] "x86_64") | ||
| 357 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvos*] "arm64") | ||
| 358 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvsimulator*] "x86_64") | ||
| 359 | + else() | ||
| 360 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos) | ||
| 361 | + endif() | ||
| 362 | + else() | ||
| 363 | + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work") | ||
| 364 | + endif() | ||
| 365 | +elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") | ||
| 366 | + set(SDK_NAME appletvsimulator) | ||
| 367 | + if(NOT ARCHS) | ||
| 368 | + set(ARCHS x86_64) | ||
| 369 | + set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos) | ||
| 370 | + else() | ||
| 371 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos) | ||
| 372 | + endif() | ||
| 373 | +elseif(PLATFORM_INT STREQUAL "WATCHOS") | ||
| 374 | + set(SDK_NAME watchos) | ||
| 375 | + if(NOT ARCHS) | ||
| 376 | + if (XCODE_VERSION_INT VERSION_GREATER 10.0) | ||
| 377 | + set(ARCHS armv7k arm64_32) | ||
| 378 | + set(APPLE_TARGET_TRIPLE_INT aarch64_32-apple-watchos) | ||
| 379 | + else() | ||
| 380 | + set(ARCHS armv7k) | ||
| 381 | + set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos) | ||
| 382 | + endif() | ||
| 383 | + else() | ||
| 384 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos) | ||
| 385 | + endif() | ||
| 386 | +elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED") | ||
| 387 | + set(SDK_NAME watchos) | ||
| 388 | + if(MODERN_CMAKE) | ||
| 389 | + if(NOT ARCHS) | ||
| 390 | + if (XCODE_VERSION_INT VERSION_GREATER 10.0) | ||
| 391 | + set(ARCHS armv7k arm64_32 i386) | ||
| 392 | + set(APPLE_TARGET_TRIPLE_INT aarch64_32-i386-apple-watchos) | ||
| 393 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k arm64_32") | ||
| 394 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386") | ||
| 395 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k arm64_32") | ||
| 396 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386") | ||
| 397 | + else() | ||
| 398 | + set(ARCHS armv7k i386) | ||
| 399 | + set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos) | ||
| 400 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k") | ||
| 401 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386") | ||
| 402 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k") | ||
| 403 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386") | ||
| 404 | + endif() | ||
| 405 | + else() | ||
| 406 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos) | ||
| 407 | + endif() | ||
| 408 | + else() | ||
| 409 | + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the WATCHOSCOMBINED setting work") | ||
| 410 | + endif() | ||
| 411 | +elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") | ||
| 412 | + set(SDK_NAME watchsimulator) | ||
| 413 | + if(NOT ARCHS) | ||
| 414 | + set(ARCHS i386) | ||
| 415 | + set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos) | ||
| 416 | + else() | ||
| 417 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos) | ||
| 418 | + endif() | ||
| 419 | +elseif(PLATFORM_INT STREQUAL "MAC" OR PLATFORM_INT STREQUAL "MAC_CATALYST") | ||
| 420 | + set(SDK_NAME macosx) | ||
| 421 | + if(NOT ARCHS) | ||
| 422 | + set(ARCHS x86_64) | ||
| 423 | + endif() | ||
| 424 | + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") | ||
| 425 | + if(PLATFORM_INT STREQUAL "MAC") | ||
| 426 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx) | ||
| 427 | + elseif(PLATFORM_INT STREQUAL "MAC_CATALYST") | ||
| 428 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) | ||
| 429 | + endif() | ||
| 430 | +elseif(PLATFORM_INT MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$") | ||
| 431 | + set(SDK_NAME macosx) | ||
| 432 | + if(NOT ARCHS) | ||
| 433 | + set(ARCHS arm64) | ||
| 434 | + endif() | ||
| 435 | + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") | ||
| 436 | + if(PLATFORM_INT STREQUAL "MAC_ARM64") | ||
| 437 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx) | ||
| 438 | + elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_ARM64") | ||
| 439 | + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) | ||
| 440 | + endif() | ||
| 441 | +else() | ||
| 442 | + message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}") | ||
| 443 | +endif() | ||
| 444 | + | ||
| 445 | +if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT CMAKE_GENERATOR MATCHES "Xcode") | ||
| 446 | + message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode") | ||
| 447 | +endif() | ||
| 448 | + | ||
| 449 | +if(CMAKE_GENERATOR MATCHES "Xcode" AND PLATFORM_INT MATCHES "MAC_CATALYST_.*") | ||
| 450 | + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") | ||
| 451 | + set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "macosx") | ||
| 452 | + set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-maccatalyst") | ||
| 453 | + if(NOT DEFINED MACOSX_DEPLOYMENT_TARGET) | ||
| 454 | + set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.15") | ||
| 455 | + else() | ||
| 456 | + set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}") | ||
| 457 | + endif() | ||
| 458 | +elseif(CMAKE_GENERATOR MATCHES "Xcode") | ||
| 459 | + set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}") | ||
| 460 | + if(NOT PLATFORM_INT MATCHES ".*COMBINED") | ||
| 461 | + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=${SDK_NAME}*] "${ARCHS}") | ||
| 462 | + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=${SDK_NAME}*] "${ARCHS}") | ||
| 463 | + endif() | ||
| 464 | +endif() | ||
| 465 | + | ||
| 466 | +# If user did not specify the SDK root to use, then query xcodebuild for it. | ||
| 467 | +if(DEFINED CMAKE_OSX_SYSROOT_INT) | ||
| 468 | + # Environment variables are always preserved. | ||
| 469 | + set(ENV{_CMAKE_OSX_SYSROOT_INT} "${CMAKE_OSX_SYSROOT_INT}") | ||
| 470 | +elseif(DEFINED ENV{_CMAKE_OSX_SYSROOT_INT}) | ||
| 471 | + set(CMAKE_OSX_SYSROOT_INT "$ENV{_CMAKE_OSX_SYSROOT_INT}") | ||
| 472 | +elseif(NOT DEFINED CMAKE_OSX_SYSROOT_INT) | ||
| 473 | + execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -version -sdk ${SDK_NAME} Path | ||
| 474 | + OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT | ||
| 475 | + ERROR_QUIET | ||
| 476 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 477 | +endif() | ||
| 478 | + | ||
| 479 | +if (NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT) | ||
| 480 | + message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain" | ||
| 481 | + "is pointing to the correct path. Please run:" | ||
| 482 | + "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer" | ||
| 483 | + "and see if that fixes the problem for you.") | ||
| 484 | + message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} " | ||
| 485 | + "does not exist.") | ||
| 486 | +elseif(DEFINED CMAKE_OSX_SYSROOT_INT) | ||
| 487 | + set(CMAKE_OSX_SYSROOT_INT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") | ||
| 488 | + # Specify the location or name of the platform SDK to be used in CMAKE_OSX_SYSROOT. | ||
| 489 | + set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") | ||
| 490 | +endif() | ||
| 491 | + | ||
| 492 | +# Use bitcode or not | ||
| 493 | +if(NOT DEFINED ENABLE_BITCODE AND NOT ARCHS MATCHES "((^|;|, )(i386|x86_64))+") | ||
| 494 | + # Unless specified, enable bitcode support by default | ||
| 495 | + message(STATUS "[DEFAULTS] Enabling bitcode support by default. ENABLE_BITCODE not provided!") | ||
| 496 | + set(ENABLE_BITCODE TRUE) | ||
| 497 | +elseif(NOT DEFINED ENABLE_BITCODE) | ||
| 498 | + message(STATUS "[DEFAULTS] Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!") | ||
| 499 | + set(ENABLE_BITCODE FALSE) | ||
| 500 | +endif() | ||
| 501 | +set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL | ||
| 502 | + "Whether or not to enable bitcode" FORCE) | ||
| 503 | +# Use ARC or not | ||
| 504 | +if(NOT DEFINED ENABLE_ARC) | ||
| 505 | + # Unless specified, enable ARC support by default | ||
| 506 | + set(ENABLE_ARC TRUE) | ||
| 507 | + message(STATUS "[DEFAULTS] Enabling ARC support by default. ENABLE_ARC not provided!") | ||
| 508 | +endif() | ||
| 509 | +set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" FORCE) | ||
| 510 | +# Use hidden visibility or not | ||
| 511 | +if(NOT DEFINED ENABLE_VISIBILITY) | ||
| 512 | + # Unless specified, disable symbols visibility by default | ||
| 513 | + set(ENABLE_VISIBILITY FALSE) | ||
| 514 | + message(STATUS "[DEFAULTS] Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!") | ||
| 515 | +endif() | ||
| 516 | +set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL "Whether or not to hide symbols from the dynamic linker (-fvisibility=hidden)" FORCE) | ||
| 517 | +# Set strict compiler checks or not | ||
| 518 | +if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE) | ||
| 519 | + # Unless specified, disable strict try_compile() | ||
| 520 | + set(ENABLE_STRICT_TRY_COMPILE FALSE) | ||
| 521 | + message(STATUS "[DEFAULTS] Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!") | ||
| 522 | +endif() | ||
| 523 | +set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL | ||
| 524 | + "Whether or not to use strict compiler checks" FORCE) | ||
| 525 | + | ||
| 526 | +# Get the SDK version information. | ||
| 527 | +if(DEFINED SDK_VERSION) | ||
| 528 | + # Environment variables are always preserved. | ||
| 529 | + set(ENV{_SDK_VERSION} "${SDK_VERSION}") | ||
| 530 | +elseif(DEFINED ENV{_SDK_VERSION}) | ||
| 531 | + set(SDK_VERSION "$ENV{_SDK_VERSION}") | ||
| 532 | +elseif(NOT DEFINED SDK_VERSION) | ||
| 533 | + execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -sdk ${CMAKE_OSX_SYSROOT_INT} -version SDKVersion | ||
| 534 | + OUTPUT_VARIABLE SDK_VERSION | ||
| 535 | + ERROR_QUIET | ||
| 536 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 537 | +endif() | ||
| 538 | + | ||
| 539 | +# Find the Developer root for the specific iOS platform being compiled for | ||
| 540 | +# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in | ||
| 541 | +# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain | ||
| 542 | +# this information from xcrun or xcodebuild. | ||
| 543 | +if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT CMAKE_GENERATOR MATCHES "Xcode") | ||
| 544 | + get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT_INT} PATH) | ||
| 545 | + get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH) | ||
| 546 | + if (NOT EXISTS "${CMAKE_DEVELOPER_ROOT}") | ||
| 547 | + message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: ${CMAKE_DEVELOPER_ROOT} does not exist.") | ||
| 548 | + endif() | ||
| 549 | +endif() | ||
| 550 | + | ||
| 551 | +# Find the C & C++ compilers for the specified SDK. | ||
| 552 | +if(DEFINED CMAKE_C_COMPILER) | ||
| 553 | + # Environment variables are always preserved. | ||
| 554 | + set(ENV{_CMAKE_C_COMPILER} "${CMAKE_C_COMPILER}") | ||
| 555 | +elseif(DEFINED ENV{_CMAKE_C_COMPILER}) | ||
| 556 | + set(CMAKE_C_COMPILER "$ENV{_CMAKE_C_COMPILER}") | ||
| 557 | +elseif(NOT DEFINED CMAKE_C_COMPILER) | ||
| 558 | + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang | ||
| 559 | + OUTPUT_VARIABLE CMAKE_C_COMPILER | ||
| 560 | + ERROR_QUIET | ||
| 561 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 562 | +endif() | ||
| 563 | +if(DEFINED CMAKE_CXX_COMPILER) | ||
| 564 | + # Environment variables are always preserved. | ||
| 565 | + set(ENV{_CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER}") | ||
| 566 | +elseif(DEFINED ENV{_CMAKE_CXX_COMPILER}) | ||
| 567 | + set(CMAKE_CXX_COMPILER "$ENV{_CMAKE_CXX_COMPILER}") | ||
| 568 | +elseif(NOT DEFINED CMAKE_CXX_COMPILER) | ||
| 569 | + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang++ | ||
| 570 | + OUTPUT_VARIABLE CMAKE_CXX_COMPILER | ||
| 571 | + ERROR_QUIET | ||
| 572 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 573 | +endif() | ||
| 574 | +# Find (Apple's) libtool. | ||
| 575 | +if(DEFINED BUILD_LIBTOOL) | ||
| 576 | + # Environment variables are always preserved. | ||
| 577 | + set(ENV{_BUILD_LIBTOOL} "${BUILD_LIBTOOL}") | ||
| 578 | +elseif(DEFINED ENV{_BUILD_LIBTOOL}) | ||
| 579 | + set(BUILD_LIBTOOL "$ENV{_BUILD_LIBTOOL}") | ||
| 580 | +elseif(NOT DEFINED BUILD_LIBTOOL) | ||
| 581 | + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find libtool | ||
| 582 | + OUTPUT_VARIABLE BUILD_LIBTOOL | ||
| 583 | + ERROR_QUIET | ||
| 584 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 585 | +endif() | ||
| 586 | +# Find the toolchain's provided install_name_tool if none is found on the host | ||
| 587 | +if(DEFINED CMAKE_INSTALL_NAME_TOOL) | ||
| 588 | + # Environment variables are always preserved. | ||
| 589 | + set(ENV{_CMAKE_INSTALL_NAME_TOOL} "${CMAKE_INSTALL_NAME_TOOL}") | ||
| 590 | +elseif(DEFINED ENV{_CMAKE_INSTALL_NAME_TOOL}) | ||
| 591 | + set(CMAKE_INSTALL_NAME_TOOL "$ENV{_CMAKE_INSTALL_NAME_TOOL}") | ||
| 592 | +elseif(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) | ||
| 593 | + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find install_name_tool | ||
| 594 | + OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT | ||
| 595 | + ERROR_QUIET | ||
| 596 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 597 | + set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE INTERNAL "") | ||
| 598 | +endif() | ||
| 599 | + | ||
| 600 | +# Configure libtool to be used instead of ar + ranlib to build static libraries. | ||
| 601 | +# This is required on Xcode 7+, but should also work on previous versions of | ||
| 602 | +# Xcode. | ||
| 603 | +get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) | ||
| 604 | +foreach(lang ${languages}) | ||
| 605 | + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> " CACHE INTERNAL "") | ||
| 606 | +endforeach() | ||
| 607 | + | ||
| 608 | +# CMake 3.14+ support building for iOS, watchOS and tvOS out of the box. | ||
| 609 | +if(MODERN_CMAKE) | ||
| 610 | + if(SDK_NAME MATCHES "iphone") | ||
| 611 | + set(CMAKE_SYSTEM_NAME iOS) | ||
| 612 | + elseif(SDK_NAME MATCHES "macosx") | ||
| 613 | + set(CMAKE_SYSTEM_NAME Darwin) | ||
| 614 | + elseif(SDK_NAME MATCHES "appletv") | ||
| 615 | + set(CMAKE_SYSTEM_NAME tvOS) | ||
| 616 | + elseif(SDK_NAME MATCHES "watch") | ||
| 617 | + set(CMAKE_SYSTEM_NAME watchOS) | ||
| 618 | + endif() | ||
| 619 | + # Provide flags for a combined FAT library build on newer CMake versions | ||
| 620 | + if(PLATFORM_INT MATCHES ".*COMBINED") | ||
| 621 | + set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO") | ||
| 622 | + set(CMAKE_IOS_INSTALL_COMBINED YES) | ||
| 623 | + message(STATUS "Will combine built (static) artifacts into FAT lib...") | ||
| 624 | + endif() | ||
| 625 | +elseif(NOT DEFINED CMAKE_SYSTEM_NAME AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10") | ||
| 626 | + # Legacy code path prior to CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified | ||
| 627 | + set(CMAKE_SYSTEM_NAME iOS) | ||
| 628 | +elseif(NOT DEFINED CMAKE_SYSTEM_NAME) | ||
| 629 | + # Legacy code path prior to CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified | ||
| 630 | + set(CMAKE_SYSTEM_NAME Darwin) | ||
| 631 | +endif() | ||
| 632 | +# Standard settings. | ||
| 633 | +set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "") | ||
| 634 | +set(UNIX TRUE CACHE BOOL "") | ||
| 635 | +set(APPLE TRUE CACHE BOOL "") | ||
| 636 | +if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64") | ||
| 637 | + set(IOS FALSE CACHE BOOL "") | ||
| 638 | + set(MACOS TRUE CACHE BOOL "") | ||
| 639 | +elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") | ||
| 640 | + set(IOS TRUE CACHE BOOL "") | ||
| 641 | + set(MACOS TRUE CACHE BOOL "") | ||
| 642 | +else() | ||
| 643 | + set(IOS TRUE CACHE BOOL "") | ||
| 644 | +endif() | ||
| 645 | +set(CMAKE_AR ar CACHE FILEPATH "" FORCE) | ||
| 646 | +set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE) | ||
| 647 | +set(CMAKE_STRIP strip CACHE FILEPATH "" FORCE) | ||
| 648 | +# Set the architectures for which to build. | ||
| 649 | +set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE INTERNAL "") | ||
| 650 | +# Change the type of target generated for try_compile() so it'll work when cross-compiling, weak compiler checks | ||
| 651 | +if(NOT ENABLE_STRICT_TRY_COMPILE_INT) | ||
| 652 | + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
| 653 | +endif() | ||
| 654 | +# All iOS/Darwin specific settings - some may be redundant. | ||
| 655 | +set(CMAKE_MACOSX_BUNDLE YES) | ||
| 656 | +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") | ||
| 657 | +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") | ||
| 658 | +set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") | ||
| 659 | +set(CMAKE_SHARED_MODULE_PREFIX "lib") | ||
| 660 | +set(CMAKE_SHARED_MODULE_SUFFIX ".so") | ||
| 661 | +set(CMAKE_C_COMPILER_ABI ELF) | ||
| 662 | +set(CMAKE_CXX_COMPILER_ABI ELF) | ||
| 663 | +set(CMAKE_C_HAS_ISYSROOT 1) | ||
| 664 | +set(CMAKE_CXX_HAS_ISYSROOT 1) | ||
| 665 | +set(CMAKE_MODULE_EXISTS 1) | ||
| 666 | +set(CMAKE_DL_LIBS "") | ||
| 667 | +set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") | ||
| 668 | +set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") | ||
| 669 | +set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") | ||
| 670 | +set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") | ||
| 671 | + | ||
| 672 | +if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+") | ||
| 673 | + set(CMAKE_C_SIZEOF_DATA_PTR 8) | ||
| 674 | + set(CMAKE_CXX_SIZEOF_DATA_PTR 8) | ||
| 675 | + if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+") | ||
| 676 | + set(CMAKE_SYSTEM_PROCESSOR "aarch64") | ||
| 677 | + else() | ||
| 678 | + set(CMAKE_SYSTEM_PROCESSOR "x86_64") | ||
| 679 | + endif() | ||
| 680 | +else() | ||
| 681 | + set(CMAKE_C_SIZEOF_DATA_PTR 4) | ||
| 682 | + set(CMAKE_CXX_SIZEOF_DATA_PTR 4) | ||
| 683 | + set(CMAKE_SYSTEM_PROCESSOR "arm") | ||
| 684 | +endif() | ||
| 685 | + | ||
| 686 | +# Note that only Xcode 7+ supports the newer more specific: | ||
| 687 | +# -m${SDK_NAME}-version-min flags, older versions of Xcode use: | ||
| 688 | +# -m(ios/ios-simulator)-version-min instead. | ||
| 689 | +if(${CMAKE_VERSION} VERSION_LESS "3.11") | ||
| 690 | + if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64") | ||
| 691 | + if(XCODE_VERSION_INT VERSION_LESS 7.0) | ||
| 692 | + set(SDK_NAME_VERSION_FLAGS | ||
| 693 | + "-mios-version-min=${DEPLOYMENT_TARGET}") | ||
| 694 | + else() | ||
| 695 | + # Xcode 7.0+ uses flags we can build directly from SDK_NAME. | ||
| 696 | + set(SDK_NAME_VERSION_FLAGS | ||
| 697 | + "-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}") | ||
| 698 | + endif() | ||
| 699 | + elseif(PLATFORM_INT STREQUAL "TVOS") | ||
| 700 | + set(SDK_NAME_VERSION_FLAGS | ||
| 701 | + "-mtvos-version-min=${DEPLOYMENT_TARGET}") | ||
| 702 | + elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") | ||
| 703 | + set(SDK_NAME_VERSION_FLAGS | ||
| 704 | + "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}") | ||
| 705 | + elseif(PLATFORM_INT STREQUAL "WATCHOS") | ||
| 706 | + set(SDK_NAME_VERSION_FLAGS | ||
| 707 | + "-mwatchos-version-min=${DEPLOYMENT_TARGET}") | ||
| 708 | + elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") | ||
| 709 | + set(SDK_NAME_VERSION_FLAGS | ||
| 710 | + "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") | ||
| 711 | + elseif(PLATFORM_INT STREQUAL "MAC") | ||
| 712 | + set(SDK_NAME_VERSION_FLAGS | ||
| 713 | + "-mmacosx-version-min=${DEPLOYMENT_TARGET}") | ||
| 714 | + else() | ||
| 715 | + # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min. | ||
| 716 | + set(SDK_NAME_VERSION_FLAGS | ||
| 717 | + "-mios-simulator-version-min=${DEPLOYMENT_TARGET}") | ||
| 718 | + endif() | ||
| 719 | +elseif(NOT PLATFORM_INT STREQUAL "MAC_CATALYST") | ||
| 720 | + # Newer versions of CMake sets the version min flags correctly, skip this for Mac Catalyst targets | ||
| 721 | + set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}) | ||
| 722 | +endif() | ||
| 723 | + | ||
| 724 | +if(DEFINED APPLE_TARGET_TRIPLE_INT) | ||
| 725 | + set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE INTERNAL "") | ||
| 726 | +endif() | ||
| 727 | + | ||
| 728 | +if(PLATFORM_INT STREQUAL "MAC_CATALYST") | ||
| 729 | + set(C_TARGET_FLAGS "-target ${APPLE_TARGET_TRIPLE_INT} -isystem ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/usr/include") | ||
| 730 | +endif() | ||
| 731 | + | ||
| 732 | +if(ENABLE_BITCODE_INT) | ||
| 733 | + set(BITCODE "-fembed-bitcode") | ||
| 734 | + set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode") | ||
| 735 | + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") | ||
| 736 | +else() | ||
| 737 | + set(BITCODE "") | ||
| 738 | + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") | ||
| 739 | +endif() | ||
| 740 | + | ||
| 741 | +if(ENABLE_ARC_INT) | ||
| 742 | + set(FOBJC_ARC "-fobjc-arc") | ||
| 743 | + set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES") | ||
| 744 | +else() | ||
| 745 | + set(FOBJC_ARC "-fno-objc-arc") | ||
| 746 | + set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO") | ||
| 747 | +endif() | ||
| 748 | + | ||
| 749 | +if(NOT ENABLE_VISIBILITY_INT) | ||
| 750 | + foreach(lang ${languages}) | ||
| 751 | + set(CMAKE_${lang}_VISIBILITY_PRESET "hidden" CACHE INTERNAL "") | ||
| 752 | + endforeach() | ||
| 753 | + set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "YES") | ||
| 754 | + set(VISIBILITY "-fvisibility=hidden -fvisibility-inlines-hidden") | ||
| 755 | +else() | ||
| 756 | + foreach(lang ${languages}) | ||
| 757 | + set(CMAKE_${lang}_VISIBILITY_PRESET "default" CACHE INTERNAL "") | ||
| 758 | + endforeach() | ||
| 759 | + set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO") | ||
| 760 | + set(VISIBILITY "-fvisibility=default") | ||
| 761 | +endif() | ||
| 762 | + | ||
| 763 | +#Check if Xcode generator is used, since that will handle these flags automagically | ||
| 764 | +if(CMAKE_GENERATOR MATCHES "Xcode") | ||
| 765 | + message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as generator.") | ||
| 766 | +else() | ||
| 767 | + # Hidden visibility is required for C++ on iOS. | ||
| 768 | + set(CMAKE_C_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}") | ||
| 769 | + set(CMAKE_CXX_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}") | ||
| 770 | + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}") | ||
| 771 | + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${CMAKE_CXX_FLAGS_MINSIZEREL}") | ||
| 772 | + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") | ||
| 773 | + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}") | ||
| 774 | + set(CMAKE_C_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") | ||
| 775 | + set(CMAKE_CXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") | ||
| 776 | + set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -arch ${CMAKE_OSX_ARCHITECTURES}") | ||
| 777 | +endif() | ||
| 778 | + | ||
| 779 | +## Print status messages to inform of the current state | ||
| 780 | +message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}") | ||
| 781 | +message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}") | ||
| 782 | +message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}") | ||
| 783 | +message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}") | ||
| 784 | +message(STATUS "Using libtool: ${BUILD_LIBTOOL}") | ||
| 785 | +message(STATUS "Using install name tool: ${CMAKE_INSTALL_NAME_TOOL}") | ||
| 786 | +if(DEFINED APPLE_TARGET_TRIPLE) | ||
| 787 | + message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}") | ||
| 788 | +endif() | ||
| 789 | +message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}" | ||
| 790 | + " (SDK version: ${SDK_VERSION})") | ||
| 791 | +if(MODERN_CMAKE) | ||
| 792 | + message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!") | ||
| 793 | +endif() | ||
| 794 | +if(CMAKE_GENERATOR MATCHES "Xcode") | ||
| 795 | + message(STATUS "Using Xcode version: ${XCODE_VERSION_INT}") | ||
| 796 | +endif() | ||
| 797 | +message(STATUS "CMake version: ${CMAKE_VERSION}") | ||
| 798 | +if(DEFINED SDK_NAME_VERSION_FLAGS) | ||
| 799 | + message(STATUS "Using version flags: ${SDK_NAME_VERSION_FLAGS}") | ||
| 800 | +endif() | ||
| 801 | +message(STATUS "Using a data_ptr size of: ${CMAKE_CXX_SIZEOF_DATA_PTR}") | ||
| 802 | +if(ENABLE_BITCODE_INT) | ||
| 803 | + message(STATUS "Bitcode: Enabled") | ||
| 804 | +else() | ||
| 805 | + message(STATUS "Bitcode: Disabled") | ||
| 806 | +endif() | ||
| 807 | + | ||
| 808 | +if(ENABLE_ARC_INT) | ||
| 809 | + message(STATUS "ARC: Enabled") | ||
| 810 | +else() | ||
| 811 | + message(STATUS "ARC: Disabled") | ||
| 812 | +endif() | ||
| 813 | + | ||
| 814 | +if(ENABLE_VISIBILITY_INT) | ||
| 815 | + message(STATUS "Hiding symbols: Disabled") | ||
| 816 | +else() | ||
| 817 | + message(STATUS "Hiding symbols: Enabled") | ||
| 818 | +endif() | ||
| 819 | + | ||
| 820 | +# Set global properties | ||
| 821 | +set_property(GLOBAL PROPERTY PLATFORM "${PLATFORM}") | ||
| 822 | +set_property(GLOBAL PROPERTY APPLE_TARGET_TRIPLE "${APPLE_TARGET_TRIPLE_INT}") | ||
| 823 | +set_property(GLOBAL PROPERTY SDK_VERSION "${SDK_VERSION}") | ||
| 824 | +set_property(GLOBAL PROPERTY XCODE_VERSION "${XCODE_VERSION_INT}") | ||
| 825 | +set_property(GLOBAL PROPERTY OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") | ||
| 826 | + | ||
| 827 | +# Export configurable variables for the try_compile() command. | ||
| 828 | +set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES | ||
| 829 | + PLATFORM | ||
| 830 | + XCODE_VERSION_INT | ||
| 831 | + SDK_VERSION | ||
| 832 | + DEPLOYMENT_TARGET | ||
| 833 | + CMAKE_DEVELOPER_ROOT | ||
| 834 | + CMAKE_OSX_SYSROOT_INT | ||
| 835 | + ENABLE_BITCODE | ||
| 836 | + ENABLE_ARC | ||
| 837 | + CMAKE_C_COMPILER | ||
| 838 | + CMAKE_CXX_COMPILER | ||
| 839 | + BUILD_LIBTOOL | ||
| 840 | + CMAKE_INSTALL_NAME_TOOL | ||
| 841 | + CMAKE_C_FLAGS | ||
| 842 | + CMAKE_CXX_FLAGS | ||
| 843 | + CMAKE_CXX_FLAGS_DEBUG | ||
| 844 | + CMAKE_CXX_FLAGS_MINSIZEREL | ||
| 845 | + CMAKE_CXX_FLAGS_RELWITHDEBINFO | ||
| 846 | + CMAKE_CXX_FLAGS_RELEASE | ||
| 847 | + CMAKE_C_LINK_FLAGS | ||
| 848 | + CMAKE_CXX_LINK_FLAGS | ||
| 849 | + CMAKE_ASM_FLAGS | ||
| 850 | + ) | ||
| 851 | + | ||
| 852 | +set(CMAKE_PLATFORM_HAS_INSTALLNAME 1) | ||
| 853 | +set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") | ||
| 854 | +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names") | ||
| 855 | +set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names") | ||
| 856 | +set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") | ||
| 857 | +set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") | ||
| 858 | +set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a") | ||
| 859 | +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") | ||
| 860 | + | ||
| 861 | +# Set the find root to the SDK developer roots. | ||
| 862 | +# Note: CMAKE_FIND_ROOT_PATH is only useful when cross-compiling. Thus, do not set on macOS builds. | ||
| 863 | +if(NOT PLATFORM_INT STREQUAL "MAC" AND NOT PLATFORM_INT STREQUAL "MAC_ARM64") | ||
| 864 | + list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") | ||
| 865 | + set(CMAKE_IGNORE_PATH "/System/Library/Frameworks;/usr/local/lib" CACHE INTERNAL "") | ||
| 866 | +endif() | ||
| 867 | + | ||
| 868 | +# Default to searching for frameworks first. | ||
| 869 | +set(CMAKE_FIND_FRAMEWORK FIRST) | ||
| 870 | + | ||
| 871 | +# Set up the default search directories for frameworks. | ||
| 872 | +if(PLATFORM_INT MATCHES "MAC_CATALYST.*") | ||
| 873 | + set(CMAKE_FRAMEWORK_PATH | ||
| 874 | + ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks | ||
| 875 | + ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks | ||
| 876 | + ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/System/Library/Frameworks | ||
| 877 | + ${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "") | ||
| 878 | +else() | ||
| 879 | + set(CMAKE_FRAMEWORK_PATH | ||
| 880 | + ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks | ||
| 881 | + ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks | ||
| 882 | + ${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "") | ||
| 883 | +endif() | ||
| 884 | + | ||
| 885 | +# By default, search both the specified iOS SDK and the remainder of the host filesystem. | ||
| 886 | +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) | ||
| 887 | + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE INTERNAL "") | ||
| 888 | +endif() | ||
| 889 | +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) | ||
| 890 | + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE INTERNAL "") | ||
| 891 | +endif() | ||
| 892 | +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) | ||
| 893 | + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE INTERNAL "") | ||
| 894 | +endif() | ||
| 895 | +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) | ||
| 896 | + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE INTERNAL "") | ||
| 897 | +endif() | ||
| 898 | + | ||
| 899 | +# | ||
| 900 | +# Some helper-macros below to simplify and beautify the CMakeFile | ||
| 901 | +# | ||
| 902 | + | ||
| 903 | +# This little macro lets you set any Xcode specific property. | ||
| 904 | +macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION) | ||
| 905 | + set(XCODE_RELVERSION_I "${XCODE_RELVERSION}") | ||
| 906 | + if(XCODE_RELVERSION_I STREQUAL "All") | ||
| 907 | + set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}") | ||
| 908 | + else() | ||
| 909 | + set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}") | ||
| 910 | + endif() | ||
| 911 | +endmacro(set_xcode_property) | ||
| 912 | + | ||
| 913 | +# This macro lets you find executable programs on the host system. | ||
| 914 | +macro(find_host_package) | ||
| 915 | + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
| 916 | + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) | ||
| 917 | + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) | ||
| 918 | + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) | ||
| 919 | + set(_TOOLCHAIN_IOS ${IOS}) | ||
| 920 | + set(IOS FALSE) | ||
| 921 | + find_package(${ARGN}) | ||
| 922 | + set(IOS ${_TOOLCHAIN_IOS}) | ||
| 923 | + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) | ||
| 924 | + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) | ||
| 925 | + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) | ||
| 926 | + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) | ||
| 927 | +endmacro(find_host_package) |
-
请 注册 或 登录 后发表评论